3 ms·
Any thoughts on golfing it smaller than: for(int i=0;i<100;printf("%d\n",100-i++)); ...I'm assuming we're talking C, with the appropriate includes, and ma
by GregBuchholz 12y ago
Any thoughts on golfing it smaller than:
for(int i=0;i<100;printf("%d\n",100-i++));
...I'm assuming we're talking C, with the appropriate includes, and main, etc..
- deleted 12y ago[deleted]
- zem 12y agoor antigolfing it :) for (int i=0;i;); printf("100\n"); printf("99\n"); /*...*/ // or if you want to be a smartass printf("100 to 1\n");
- tempestn 12y agoI really hope someone tried that in the interview.
- bko 12y agofor(int i=0;i<99;printf("%d\n",101-++i));
- im3w1l 12y agoDoesn't print 1.
- frobozz 12y agoYou can easily save one more character. The problem doesn't say anything about newlines.
- im3w1l 12y agofor(int i=101;--i;)printf("%d\n",i); Assuming int main(int a) we can do a<100&&main(a+1);printf("%d\n",a); EDIT: missed constraint that it needs to start with for(int i=0 from article.
- ConceptJunkie 12y agoIt's too bad the constraint wasn't what you said it was, because then you could do: for ( int i = 0144; or for ( int i = 0x64; Unfortunately, the constraint was "for ( int i = 0;". :-/