4 ms·
Every time fizzbuzz comes up, someone has to post a solution it seems, but why does everyone write such huge fizzbuzz programs? for(int i=1; i <= 100; i++)
by Steve_Baker 15y ago
Every time fizzbuzz comes up, someone has to post a solution it seems, but why does everyone write such huge fizzbuzz programs?
for(int i=1; i <= 100; i++)
printf((char *[]){"%d\n","Buzz\n","Fizz\n","FizzBuzz\n"}[((i%3==0)<<1)|((i%5)==0)], i);
- kenrikm 15y agoI posted it as a joke: http://www.codeslate.com/2007/01/you-dont-bury-survivors.html http://www.codeslate.com/2007/01/you-dont-bury-survivors.htm... However, yes it is huge it's Objective C with whitespace what do you expect? ;)
- Tyrannosaurs 15y agoSome people value readability, some compactness / efficiency. Why they do it one way or another is an occasionally interesting follow up question.
- kenrikm 15y agoI'm in the readability camp, I'm one to comment my code even if it's something simple and I also like to use verbose variable names. I always keep in the back of my mind that if someone had to pick up my code without knowing how anything was implemented they might appreciate my efforts (even if it's just a personal project that I don't plan on anyone seeing). You can't please everyone I'm sure for as many people that like it compact there are people that like the whitespace.
- fhars 15y agoA bit long, isn't it? 1_,`0:'{:[~x!15;"FizzBuzz";~x!3;"Fizz";~x!5;"Buzz";$x],"\n"}'1+!100 (Thats https://github.com/kevinlawler/kona https://github.com/kevinlawler/kona) [Edit: Found a way to shave off three chars]