Looping:
Variable declarations:
int max;
for(int i=1;i<max;i++){
}
become:
int max,i=1;
for(;i<max;i++){
}
And if you have a need to or work with the i variable only once, you could start at -1 (or 0 depending on the loop circumstance) and increment inline:
int max,i=1;
for(;i<max;i++){
Console.WriteLine(i);
}
to
int max,i=1;
for(;i<max;){
Console.WriteLine(++i);
}
And that reduces by one character, and slightly obfuscates the code as well. Only do that to the FIRST i
reference, like thus: (granted one character optimizations aren't much, but they can help)
int max,i=1;
for(;i<max;i++){
Console.WriteLine(i + " " + i);
}
to
int max,i=1;
for(;i<max;){
Console.WriteLine(++i + " " + i);
}
when the loop does not have to increment i
(reverse order loop):
for(int i=MAX;--i>0;){
Console.WriteLine(i);
}
BEST TIP => Use something beside .NET if you don't want to submit the longest answer for the challenge. .NET is designed to be very verbose and to let the IDE do the typing. Which is actually not as bad as it sounds for general programming as long as you have that IDE crutch but for code golf that strategy is certain fail. – krowe – 2014-07-02T05:48:05.340
Forgive me for the picture of a calendar, it was all I could find on short notice. – undergroundmonorail – 2014-07-08T12:44:05.907