Last active
February 11, 2021 14:01
-
-
Save 17twenty/3019174 to your computer and use it in GitHub Desktop.
Shortest FizzBuzz in C. Implicit declaration of printf but libc is linked against any way so nyeh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main(i){for(;i++<100;)printf(i%3?i%5?"%d\n":"Buzz\n":i%5?"Fizz\n":"FizzBuzz\n",i);} |
Shaved another 4 off that:
main(i){for(;i<101;puts(i++%5?"":"buzz"))printf("%i\r%s",i,i%3?"":"fizz");}
oh that is nice Gavin!
Shaved another 4 off that:
main(i){for(;i<101;puts(i++%5?"":"buzz"))printf("%i\r%s",i,i%3?"":"fizz");}
-1 bytes by changing printf()
main(i){for(;i<101;puts(i++%5?"":"Buzz"))printf(i%3?i%5?"%d":0:"Fizz",i);}
removing the stop condition brings it down to 69 bytes and is still technically fizzbuzz
main(i){for(;;puts(i++%5?"":"Buzz"))printf(i%3?i%5?"%d":0:"Fizz",i);}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shaved 10 characters off it:
main(i){for(i--;i++<100;)printf("%i%s%s\n",i,i%3?"\r":"\rfizz",i%5?"":"buzz");}