It's time for awesome classic golf!
So, we have a function in C # or a similar language:
void Print(int min, int max) { if (min > max) throw new ArgumentException(); checked // бросаем исключение при переполнении { for (int i = min /*----------------*/) Console.WriteLine(i); } } It is necessary to replace the comment /*----------------*/ with a single-line code so that as a result of the execution of this function, all numbers from min to max inclusive are output to the console. More can not be changed!
Wins the shortest decision on the number of characters added . It is allowed to use not only C #, but a for loop must be present in the language (in this case, replace the code with the same one). The function should work without errors.
Yes, solutions based on overflows are prohibited (using checked ) so that there is not much difference between C # and C ++.
Notice special cases like min == int.Min , max == int.Max , min == max and the like. We can assume that min <= max when calling.
Final result:
The @kmv, @pavel and @Zealint solutions are correct, and they essentially implement one idea. The minimum size is 17 characters.
The second solution @kmv is longer (about 50 characters), but with a completely crazy (in a positive sense) idea.
An excellent non-standard first @kodv solution took 38 characters, the second solution of the same author is similar to the @Qwertiy solution, at least 30 characters.
Another solution @Qwertiy more traditional is also unusual, currently 26 characters.
The decisions of the other participants so far do not seem to fit the condition.
Unfortunately, due to the insufficiently unambiguous formulation of the condition, the @jfs decision on Python caused a discussion, and in the end was withdrawn by the author. Error in the condition completely on my conscience, I apologize.
mintomaxinclusive" - Cerbofor i in min .. max -> printfn "%d" i- in general cheating :) - kmv