├── fizzbuzz106.c ├── Makefile ├── fizzbuzz108.c ├── fizzbuzz030.c ├── fizzbuzz092.c ├── fizzbuzz107.c ├── fizzbuzz008.c ├── fizzbuzz069.c ├── fizzbuzz130.c ├── fizzbuzz029.c ├── fizzbuzz009.c ├── fizzbuzz042.c ├── fizzbuzz031.c ├── fizzbuzz014.c ├── fizzbuzz028.c ├── fizzbuzz007.c ├── fizzbuzz111.c ├── fizzbuzz104.c ├── fizzbuzz118.c ├── fizzbuzz132.c ├── fizzbuzz062.c ├── fizzbuzz072.c ├── fizzbuzz103.c ├── fizzbuzz115.c ├── fizzbuzz085.c ├── fizzbuzz102.c ├── fizzbuzz025.c ├── fizzbuzz110.c ├── fizzbuzz145.c ├── fizzbuzz018.c ├── fizzbuzz038.c ├── fizzbuzz046.c ├── fizzbuzz131.c ├── fizzbuzz078.c ├── fizzbuzz082.c ├── fizzbuzz045.c ├── fizzbuzz043.c ├── fizzbuzz052.c ├── fizzbuzz044.c ├── fizzbuzz120.c ├── fizzbuzz016.c ├── fizzbuzz051.c ├── fizzbuzz041.c ├── fizzbuzz001.c ├── fizzbuzz083.c ├── fizzbuzz127.c ├── fizzbuzz065.c ├── fizzbuzz121.c ├── fizzbuzz005.c ├── fizzbuzz077.c ├── fizzbuzz096.c ├── fizzbuzz101.c ├── fizzbuzz002.c ├── fizzbuzz011.c ├── fizzbuzz006.c ├── fizzbuzz013.c ├── fizzbuzz024.c ├── fizzbuzz019.c ├── fizzbuzz073.c ├── fizzbuzz017.c ├── fizzbuzz097.c ├── fizzbuzz137.c ├── fizzbuzz032.c ├── fizzbuzz015.c ├── fizzbuzz086.c ├── fizzbuzz129.c ├── fizzbuzz033.c ├── fizzbuzz036.c ├── fizzbuzz084.c ├── fizzbuzz023.c ├── fizzbuzz116.c ├── fizzbuzz034.c ├── fizzbuzz098.c ├── fizzbuzz080.c ├── fizzbuzz128.c ├── fizzbuzz091.c ├── fizzbuzz112.c ├── fizzbuzz035.c ├── fizzbuzz138.c ├── fizzbuzz022.c ├── fizzbuzz050.c ├── fizzbuzz012.c ├── fizzbuzz003.c ├── fizzbuzz117.c ├── fizzbuzz093.c ├── fizzbuzz010.c ├── fizzbuzz136.c ├── fizzbuzz139.c ├── fizzbuzz004.c ├── fizzbuzz144.c ├── fizzbuzz142.c ├── fizzbuzz048.c ├── fizzbuzz122.c ├── fizzbuzz037.c ├── fizzbuzz066.c ├── fizzbuzz090.c ├── fizzbuzz026.c ├── fizzbuzz049.c ├── fizzbuzz047.c ├── fizzbuzz056.c ├── fizzbuzz057.c ├── fizzbuzz141.c ├── fizzbuzz020.c ├── fizzbuzz126.c ├── fizzbuzz040.c ├── fizzbuzz081.c ├── fizzbuzz119.c ├── fizzbuzz070.c ├── fizzbuzz094.c ├── fizzbuzz060.c ├── fizzbuzz039.c ├── fizzbuzz059.c ├── fizzbuzz063.c ├── expected-output.txt ├── fizzbuzz146.c ├── fizzbuzz055.c ├── fizzbuzz058.c ├── fizzbuzz076.c ├── fizzbuzz071.c ├── fizzbuzz021.c ├── fizzbuzz135.c ├── fizzbuzz079.c ├── fizzbuzz105.c ├── fizzbuzz068.c ├── fizzbuzz113.c ├── fizzbuzz133.c ├── fizzbuzz143.c ├── fizzbuzz140.c ├── fizzbuzz087.c ├── fizzbuzz027.c ├── fizzbuzz100.c ├── fizzbuzz088.c ├── fizzbuzz099.c ├── fizzbuzz114.c ├── fizzbuzz089.c ├── fizzbuzz053.c ├── fizzbuzz123.c ├── fizzbuzz124.c ├── list.txt ├── fizzbuzz109.c ├── fizzbuzz067.c ├── fizzbuzz134.c ├── fizzbuzz061.c ├── verify ├── fizzbuzz125.c ├── fizzbuzz095.c ├── portability.md ├── fizzbuzz064.c ├── fizzbuzz054.c ├── fizzbuzz075.c └── README.md /fizzbuzz106.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | list.txt: 2 | git ls-files 'fizzbuzz*.c' > $@ 3 | -------------------------------------------------------------------------------- /fizzbuzz108.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i++) { 4 | printf("%.*s%.*s%.d\n", 4*!(i%3), "Fizz", 4*!(i%5), "Buzz", (i%3&&i%5)*i); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fizzbuzz030.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | printf((char*[]){"%d\n","Fizz\n","Buzz\n","FizzBuzz\n"}[!(i%3)+(!(i%5)<<1)],i); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fizzbuzz092.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i % 15 == 0 ? puts("FizzBuzz") : i % 3 == 0 ? puts("Fizz") : i % 5 == 0 ? puts("Buzz") : printf("%d\n", i), i < 100; i ++); 4 | } 5 | -------------------------------------------------------------------------------- /fizzbuzz107.c: -------------------------------------------------------------------------------- 1 | #include 2 | LINE02 3 | LINE03 4 | LINE04 5 | LINE05 6 | LINE06 7 | LINE07 8 | LINE08 9 | LINE09 10 | LINE10 11 | LINE11 12 | LINE12 13 | LINE13 14 | LINE14 15 | LINE15 16 | LINE16 17 | LINE17 18 | -------------------------------------------------------------------------------- /fizzbuzz008.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | i % 3 && i % 5 ? printf("%d\n", i) : 5 | puts(!(i % 15) ? "FizzBuzz" : !(i % 3) ? "Fizz" : "Buzz"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fizzbuzz069.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | FILE *f = fopen("expected-output.txt", "r"); 4 | int c; 5 | while ((c = fgetc(f)) != EOF) { 6 | putchar(c); 7 | } 8 | fclose(f); 9 | } 10 | -------------------------------------------------------------------------------- /fizzbuzz130.c: -------------------------------------------------------------------------------- 1 | int(puts)(const/**/char*s);int(printf)(const/**/char*format,...);int(main)(void){for(int/**/i=1;i<=100;i++)if(i%15==0){puts("FizzBuzz");}else/**/if(i%3==0){puts("Fizz");}else/**/if(i%5==0)puts("Buzz");else{printf("%d\n",i);}} 2 | -------------------------------------------------------------------------------- /fizzbuzz029.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const char *const fmt[] = { "%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" }; 4 | for (int i = 1; i <= 100; i ++) { 5 | printf(fmt[!(i%3) + (!(i%5)<<1)], i); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fizzbuzz009.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int m3 = !(i%3); 5 | int m5 = !(i%5); 6 | !(m3|m5)?printf("%d\n",i):puts(m3&m5?"FizzBuzz":m3?"Fizz":"Buzz"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz042.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | printf(printf("%s%s", 5 | i%3 ? "" : "Fizz", 6 | i%5 ? "" : "Buzz") ? "\n" : "%d\n", i); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz031.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | const int three = printf(i % 3 ? "" : "Fizz"); 5 | three + printf(i % 5 ? "" : "Buzz") || printf("%d", i); 6 | putchar('\n'); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz014.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int c = 0; 5 | i%3||(c+=printf("Fizz")); 6 | i%5||(c+=printf("Buzz")); 7 | c||printf("%d", i); 8 | putchar('\n'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz028.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const char *const s[] = { NULL, "Fizz", "Buzz", "FizzBuzz" }; 4 | for (int i = 1; i <= 100; i ++) { 5 | const int x = !(i%3) + (!(i%5)<<1); 6 | s[x] ? puts(s[x]) : printf("%d\n", i); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz007.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | !(i%15) && (puts("FizzBuzz")||1ll) || 5 | !(i%3) && (puts("Fizz")||1ll) || 6 | !(i%5) && (puts("Buzz")||1ll) || 7 | printf("%d\n", i); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fizzbuzz111.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void FizzBuzz(int n) { 4 | n - 1 ? FizzBuzz(n - 1) : (void)FizzBuzz, 5 | n % 15 ? n % 3 ? n % 5 ? 6 | printf("%d\n", n) : puts("Buzz") : puts("Fizz") : puts("FizzBuzz"); 7 | } 8 | 9 | int main(void) { 10 | FizzBuzz(100); 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz104.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int p = 0; 5 | i % 3 || fputs((p++, "Fizz"), stdout); 6 | i % 5 || fputs((p++, "Buzz"), stdout); 7 | p || printf("%d", i); 8 | putchar('\n'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz118.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | const int x = !(i%5)<<1|!(i%3); 5 | x&1 && fputs("Fizz", stdout); 6 | x&2 && fputs("Buzz", stdout); 7 | x&3 || printf("%d", i); 8 | putchar('\n'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz132.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int m3, m5; 5 | (m3 = i % 3) || fputs("Fizz", stdout); 6 | (m5 = i % 5) || fputs("Buzz", stdout); 7 | m3 && m5 && printf("%d", i); 8 | putchar('\n'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz062.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | printf(i % 15 == 0 ? "FizzBuzz\n" : 5 | i % 3 == 0 ? "Fizz\n" : 6 | i % 5 == 0 ? "Buzz\n" : 7 | "%d\n", 8 | i); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz072.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define I printf("%d\n",i++); 3 | #define F puts("Fizz");i++; 4 | #define B puts("Buzz");i++; 5 | #define Z puts("FizzBuzz");i++; 6 | #define S s: 7 | int main(void) { 8 | int i = 1; 9 | goto s; 10 | do { I F I I Z S I I F I B F I I F B } while (i < 100); 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz103.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int p = 0; 5 | p || i % 15 || puts((p++, "FizzBuzz")); 6 | p || i % 3 || puts((p++, "Fizz")); 7 | p || i % 5 || puts((p++, "Buzz")); 8 | p || printf("%d\n", i); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz115.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const char *format = "FizzBuzz\n\0Fizz\n\0%d\n"; 4 | for (int i = 1; i <= 100; i ++) { 5 | printf(format + (i % 15 == 0 ? 0 : 6 | i % 3 == 0 ? 10 : 7 | i % 5 == 0 ? 4 : 16), i); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fizzbuzz085.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | i % 3 == 0 && fputs("Fizz", stdout); 5 | i % 3 != 0 && i % 5 != 0 && printf("%d", i); 6 | i % 5 == 0 && fputs("Buzz", stdout); 7 | putchar('\n'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fizzbuzz102.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | for (int i = 1; i <= 100; i ++) { 5 | char line[10]; 6 | sprintf(line, "%s%s%d", i % 3 ? "" : "Fizz", i % 5 ? "" : "Buzz", i * 10 * (i % 3 && i % 5)); 7 | *strchr(line, '0') = '\0'; 8 | puts(line); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz025.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(void) { 5 | for (int i = 1; i <= 100; i ++) { 6 | int n = 0; 7 | i%3 || printf("%s%n", "Fizz", &n); 8 | i%5 || printf("%s%n", "Buzz", &n); 9 | n || printf("%d", i); 10 | putchar('\n'); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fizzbuzz110.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void FizzBuzz(int n) { 4 | n - 1 ? FizzBuzz(n - 1) : (void)FizzBuzz, 5 | n % 15 == 0 ? puts("FizzBuzz") : 6 | n % 3 == 0 ? puts("Fizz") : 7 | n % 5 == 0 ? puts("Buzz") : 8 | printf("%d\n", n); 9 | } 10 | 11 | int main(void) { 12 | FizzBuzz(100); 13 | } 14 | -------------------------------------------------------------------------------- /fizzbuzz145.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) 4 | !(i % 15) && printf(("%s\n", (15,0)+"FizzBuzz")) || 5 | !(i % 3) && printf(("%s\n", (3,4)+"BuzzFizz")) || 6 | !(i % 5) && printf(("%s\n", (5,4)+"FizzBuzz")) || 7 | ~(i % 7) && printf((i, "%d"), i), puts(("\n", "")); 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz018.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | if (i%3*(i%5)) { 5 | printf("%d\n", i); 6 | } 7 | else { 8 | i%3||fputs("Fizz", stdout); 9 | i%5||fputs("Buzz", stdout); 10 | putchar('\n'); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fizzbuzz038.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; ; i += 15) { 4 | printf("%d\n%d\nFizz\n%d\nBuzz\nFizz\n%d\n%d\nFizz\nBuzz\n", 5 | i, i+1, i+3, i+6, i+7); 6 | if (i+10 > 100) break; 7 | printf("%d\nFizz\n%d\n%d\nFizzBuzz\n", 8 | i+10, i+12, i+13); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz046.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(void) { 5 | for (int i = 1; i <= 100; i ++) { 6 | char line[9] = ""; 7 | i % 3 || strcat(line, "Fizz"); 8 | i % 5 || strcat(line, "Buzz"); 9 | *line || sprintf(line, "%d", i); 10 | puts(line); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fizzbuzz131.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | for (int i = 1; i <= 100; i ++) { 5 | bool by3, by5; 6 | by3 = i % 3 == 0 && 1+fputs("Fizz", stdout); 7 | by5 = i % 5 == 0 && 1+fputs("Buzz", stdout); 8 | by3 || by5 || printf("%d", i); 9 | putchar('\n'); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz078.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | for(uint16_t i=18561;(i&127)<=100;i+=18561)(i&49152)==49152&&(i&=~ 5 | 49152),(i&14336)==10240&&(i&=~14336),(i&1920)==1920&&(i&=~1920),(! 6 | (i&1920))&&(puts("FizzBuzz"),1)||(!(i&49152))&&(puts("Fizz"),1)||( 7 | !(i&14336))&&(puts("Buzz"),1)||printf("%u\n",i&127); 8 | } 9 | -------------------------------------------------------------------------------- /fizzbuzz082.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | switch (!(i%5)<<1^!(i%3)) { 5 | case 0: printf("%d\n", i); break; 6 | case 1: puts("Fizz"); break; 7 | case 2: puts("Buzz"); break; 8 | case 3: puts("FizzBuzz"); break; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz045.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | char format[12]; 5 | sprintf(format, 6 | "%%%ss%%%ss%s\n", 7 | i%3?".0":"", 8 | i%5?".0":"", 9 | i%3&&i%5?"%d":""); 10 | printf(format, "Fizz", "Buzz", i); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fizzbuzz043.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | char format[] = "%d\n%d\nFizz\n%d\nBuzz\nFizz\n%d\n%d\nFizz\nBuzz\n%d\nFizz\n%d\n%d\nFizzBuzz\n"; 4 | for (int i = 1; i <= 100; i += 15) { 5 | if (i == 91) { 6 | format[40] = '\0'; 7 | } 8 | printf(format, i, i+1, i+3, i+6, i+7, i+10, i+12, i+13); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fizzbuzz052.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | switch (3&19142723>>i%017*2) { 5 | case 0: printf("%d\n", i); break; 6 | case 1: puts("Fizz"); break; 7 | case 2: puts("Buzz"); break; 8 | case 3: puts("FizzBuzz"); break; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz044.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | for (int i = 1; i <= 100; i ++) { 5 | char format[12] = ""; 6 | strcat(format, i % 3 ? "%.0s" : "%s"); 7 | strcat(format, i % 5 ? "%.0s" : "%s"); 8 | strcat(format, format[7] ? "%d\n" : "\n"); 9 | printf(format, "Fizz", "Buzz", i); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz120.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | switch ((3 << (i%15*2) & 19142723) >> (i%15*2)) { 5 | case 0: printf("%d\n", i); break; 6 | case 1: puts("Fizz"); break; 7 | case 2: puts("Buzz"); break; 8 | case 3: puts("FizzBuzz"); break; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz016.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizzbuzz(int i) { 4 | if (i > 1) { 5 | fizzbuzz(i-1); 6 | } 7 | if (i % 15 == 0) { puts("FizzBuzz"); } 8 | else if (i % 3 == 0) { puts("Fizz"); } 9 | else if (i % 5 == 0) { puts("Buzz"); } 10 | else { printf("%d\n", i); } 11 | } 12 | 13 | int main(void) { 14 | fizzbuzz(100); 15 | } 16 | -------------------------------------------------------------------------------- /fizzbuzz051.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 0; i < 100; i ++) { 4 | switch ((i%15)["[[][\"][[]\"[][['"]) { 5 | case '[': printf("%d\n", i+1); break; 6 | case ']': puts("Fizz"); break; 7 | case '"': puts("Buzz"); break; 8 | case '\'': puts("FizzBuzz"); break; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fizzbuzz041.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | char s[4]; 5 | sprintf(s, "%d", i); 6 | int three = 3*5*!(i%3); 7 | int five = 3*5*!(i%5); 8 | printf("%.*s", three, "Fizz"); 9 | printf("%.*s", five, "Buzz"); 10 | printf("%.*s", 3*5*!(three+five), s); 11 | putchar('\n'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fizzbuzz001.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | if (i % 15 == 0) { 5 | puts("FizzBuzz"); 6 | } 7 | else if (i % 3 == 0) { 8 | puts("Fizz"); 9 | } 10 | else if (i % 5 == 0) { 11 | puts("Buzz"); 12 | } 13 | else { 14 | printf("%d\n", i); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz083.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void func0(int n) { printf("%d\n", n); } 4 | static void func1(int n) { puts("Fizz"); } 5 | static void func2(int n) { puts("Buzz"); } 6 | static void func3(int n) { puts("FizzBuzz"); } 7 | static void (*const p[])(int) = { func0, func1, func2, func3 }; 8 | 9 | int main(void) { 10 | for (int i = 1; i <= 100; i ++) { 11 | (!(i%5)<<1^!(i%3))[p](i); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fizzbuzz127.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | int i = 101; 4 | while (--i) { 5 | if (i % 15 == 11) { 6 | puts("FizzBuzz"); 7 | } 8 | else if (i % 3 == 2) { 9 | puts("Fizz"); 10 | } 11 | else if (i % 5 == 1) { 12 | puts("Buzz"); 13 | } 14 | else { 15 | printf("%d\n", 101-i); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fizzbuzz065.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | _10:; int i = 1; 4 | _20: if (i > 100) goto _150; 5 | _30: if (i % 15 == 0) goto _120; 6 | _40: if (i % 3 == 0) goto _80; 7 | _50: if (i % 5 == 0) goto _100; 8 | _60: printf("%d\n", i); 9 | _70: goto _130; 10 | _80: puts("Fizz"); 11 | _90: goto _130; 12 | _100: puts("Buzz"); 13 | _110: goto _130; 14 | _120: puts("FizzBuzz"); 15 | _130: i = i + 1; 16 | _140: goto _20; 17 | _150:;} 18 | -------------------------------------------------------------------------------- /fizzbuzz121.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void num(int n) { printf("%d\n", n); } 4 | static void fizz(int n) { puts("Fizz"); } 5 | static void buzz(int n) { puts("Buzz"); } 6 | static void fizzbuzz(int n) { puts("FizzBuzz"); } 7 | static void (*const f[])(int) = { num, fizz, buzz, fizzbuzz }; 8 | 9 | int main(void) { 10 | for (int i = 1; i <= 100; i ++) { 11 | f[(3 << (i%15*2) & 19142723) >> (i%15*2)](i); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fizzbuzz005.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int chars_printed = 0; 5 | if (i % 3 == 0) { 6 | chars_printed += printf("Fizz"); 7 | } 8 | if (i % 5 == 0) { 9 | chars_printed += printf("Buzz"); 10 | } 11 | if (chars_printed == 0) { 12 | printf("%d", i); 13 | } 14 | putchar('\n'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fizzbuzz077.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1, x = 1, y = 1, z = 1; 4 | i <= 100; 5 | i ++, x ++, y ++, z ++) 6 | { 7 | x == 3 && (x = 0); 8 | y == 5 && (y = 0); 9 | z == 15 && (z = 0); 10 | if (!z) puts("FizzBuzz"); 11 | else if (!x) puts("Fizz"); 12 | else if (!y) puts("Buzz"); 13 | else printf("%d\n", i); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fizzbuzz096.c: -------------------------------------------------------------------------------- 1 | %:include 2 | 3 | static void func0(int n) <% printf("%d\n", n); ??> 4 | static void func1(int n) <% puts("Fizz"); %> 5 | static void func2(int n) ??< puts("Buzz"); ??> 6 | static void func3(int n) ??< puts("FizzBuzz"); %> 7 | static void (*const p<::>)(int) = ??< func0, func1, func2, func3 %>; 8 | 9 | int main(void) ??< 10 | for (int i = 1; i <= 100; i ++) <% 11 | (!(i%5)<<1??'!(i%3))??(p:>(i); 12 | %> 13 | %> 14 | -------------------------------------------------------------------------------- /fizzbuzz101.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static char *nostrcat(char *dest, const char *src){return dest;} 5 | 6 | int main(void) { 7 | for (int i = 1; i <= 100; i ++) { 8 | char line[9] = { 0 }, num[4]; 9 | (i % 3 ? nostrcat : strcat)(line, "Fizz"); 10 | (i % 5 ? nostrcat : strcat)(line, "Buzz"); 11 | (line[0] ? nostrcat : strcat)(line, (sprintf(num, "%d", i), num)); 12 | puts(line); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /fizzbuzz002.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | int printed = 0; 5 | if (i % 3 == 0) { 6 | fputs("Fizz", stdout); 7 | printed = 1; 8 | } 9 | if (i % 5 == 0) { 10 | fputs("Buzz", stdout); 11 | printed = 1; 12 | } 13 | if (!printed) { 14 | printf("%d", i); 15 | } 16 | putchar('\n'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fizzbuzz011.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz (int n) { puts("Fizz"); } 4 | static void buzz (int n) { puts("Buzz"); } 5 | static void fizzbuzz (int n) { puts("FizzBuzz"); } 6 | static void print (int n) { printf("%d\n", n); } 7 | 8 | static void (*func(int n))(int) { 9 | return !(n%15) ? fizzbuzz : !(n%3) ? fizz : !(n%5) ? buzz : print; 10 | } 11 | 12 | int main(void) { 13 | for (int i = 1; i <= 100; i ++) { 14 | func(i)(i); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fizzbuzz006.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | char num[4]; 4 | char *output[3][2] = { 5 | { "", "Fizz" }, 6 | { "", "Buzz" }, 7 | { "", num } 8 | }; 9 | for (int i = 1; i <= 100; i ++) { 10 | int m3 = !(i%3); 11 | int m5 = !(i%5); 12 | sprintf(num, "%d", i); 13 | printf("%s%s%s\n", 14 | output[0][m3], 15 | output[1][m5], 16 | output[2][!m3&!m5]); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fizzbuzz013.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void print (int n) { printf("%d", n); } 4 | static void fizz (int n) { fputs("Fizz", stdout); } 5 | static void buzz (int n) { fputs("Buzz", stdout); } 6 | static void fizzbuzz (int n) { fizz(n); buzz(n); } 7 | 8 | static void (*const arr[])(int) = { print, fizz, buzz, fizzbuzz }; 9 | 10 | int main(void) { 11 | for (int i = 1; i <= 100; i ++) { 12 | arr[!(i%3)+(!(i%5)<<1)](i); 13 | putchar('\n'); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fizzbuzz024.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(void) { 5 | for (int i = 1; i <= 100; i ++) { 6 | char line[9]; 7 | line[0] = '\0'; 8 | if (i % 3 == 0) { 9 | strcat(line, "Fizz"); 10 | } 11 | if (i % 5 == 0) { 12 | strcat(line, "Buzz"); 13 | } 14 | if (line[0] == '\0') { 15 | sprintf(line, "%d", i); 16 | } 17 | puts(line); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fizzbuzz019.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; ; i += 15) { 4 | printf("%d\n%d\n", i, i+1); 5 | puts("Fizz"); 6 | printf("%d\n", i+3); 7 | puts("Buzz"); 8 | puts("Fizz"); 9 | printf("%d\n%d\n", i+6, i+7); 10 | puts("Fizz\nBuzz"); 11 | if (i+10 > 100) break; 12 | printf("%d\n", i+10); 13 | puts("Fizz"); 14 | printf("%d\n%d\n", i+12, i+13); 15 | puts("FizzBuzz"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz073.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | char line[100][9]; 5 | for (int i = 1; i <= 100; i ++ ) { 6 | sprintf(line[i-1], "%d", i); 7 | } 8 | for (int i = 3; i <= 100; i += 3) { 9 | strcpy(line[i-1], "Fizz"); 10 | } 11 | for (int i = 5; i <= 100; i += 5) { 12 | (line[i-1][0] == 'F' ? strcat : strcpy)(line[i-1], "Buzz"); 13 | } 14 | for (int i = 1; i <= 100; i ++) { 15 | puts(line[i-1]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz017.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizzbuzz(int lo, int hi) { 4 | if (lo <= hi) { 5 | const int i = (lo + hi) / 2; 6 | if (lo < hi) fizzbuzz(lo, i-1); 7 | if (i % 15 == 0) puts("FizzBuzz"); 8 | else if (i % 3 == 0) puts("Fizz"); 9 | else if (i % 5 == 0) puts("Buzz"); 10 | else printf("%d\n", i); 11 | if (lo < hi) fizzbuzz(i+1, hi); 12 | } 13 | } 14 | 15 | int main(void) { 16 | fizzbuzz(1, 100); 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz097.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | FILE *nowhere = tmpfile(); 4 | FILE *fizz, *buzz, *num, *newline; 5 | for (int i = 1; i <= 100; i ++) { 6 | fizz = i % 3 ? nowhere : stdout; 7 | buzz = i % 5 ? nowhere : stdout; 8 | num = fizz == stdout || buzz == stdout ? nowhere : stdout; 9 | newline = stdout; 10 | fputs("Fizz", fizz); 11 | fputs("Buzz", buzz); 12 | fprintf(num, "%d", i); 13 | putc('\n', newline); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fizzbuzz137.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static const char *line(int i) { 4 | switch (i % 15) { 5 | case 3: case 6: case 9: case 12: return "Fizz"; 6 | case 0: case 5: case 10: return "FizzBuzz" + (4*!!(i%15)); 7 | default:; 8 | static char s[3]; 9 | s[0] = '0' + i / 10; 10 | s[1] = '0' + i % 10; 11 | return s + (i<10); 12 | } 13 | } 14 | 15 | int main(void) { 16 | for (int i = 1; i <= 100; i ++) { 17 | puts(line(i)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fizzbuzz032.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | char output[900] = ""; 5 | for (int i = 18; i < 900; i += 27) { 6 | strcpy(output + i, "Fizz"); 7 | } 8 | for (int i = 36; i < 900; i += 45) { 9 | strcat(output + i, "Buzz"); 10 | } 11 | for (int i = 0; i < 900; i += 9) { 12 | if (!output[i]) { 13 | sprintf(output + i, "%d", i/9+1); 14 | } 15 | } 16 | for (int i = 0; i < 900; i += 9) { 17 | puts(output + i); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fizzbuzz015.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | switch (i%15) { 5 | case 0: 6 | puts("FizzBuzz"); 7 | break; 8 | case 3: case 6: case 9: case 12: 9 | puts("Fizz"); 10 | break; 11 | case 5: case 10: 12 | puts("Buzz"); 13 | break; 14 | default: 15 | printf("%d\n", i); 16 | break; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fizzbuzz086.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void update(FILE **f, int i) { 4 | fclose(stderr); 5 | f[0] = i % 3 == 0 ? stdout : stderr; 6 | f[1] = i % 5 == 0 ? stdout : stderr; 7 | f[2] = (i % 3 == 0 || i % 5 == 0) ? stderr : stdout; 8 | f[3] = stdout; 9 | } 10 | 11 | int main(void) { 12 | FILE *f[4]; 13 | for (int i = 1; i <= 100; i ++) { 14 | update(f, i); 15 | fputs("Fizz", f[0]); 16 | fputs("Buzz", f[1]); 17 | fprintf(f[2], "%d", i); 18 | putc('\n', f[3]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fizzbuzz129.c: -------------------------------------------------------------------------------- 1 | int(puts)(const/**/char*s);int(main)(void){puts("1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz");} 2 | -------------------------------------------------------------------------------- /fizzbuzz033.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | int imod3 = 0, imod5 = 0; 4 | for (int i = 1; i <= 100; i ++) { 5 | imod3 ++; if (imod3 == 3) imod3 = 0; 6 | imod5 ++; if (imod5 == 5) imod5 = 0; 7 | if (imod3 == 0 && imod5 == 0) { 8 | puts("FizzBuzz"); 9 | } 10 | else if (imod3 == 0) { 11 | puts("Fizz"); 12 | } 13 | else if (imod5 == 0) { 14 | puts("Buzz"); 15 | } 16 | else { 17 | printf("%d\n", i); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fizzbuzz036.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | switch ((i-1)["ddfdbfddfbdfddFddfdbfddfb" 5 | "dfddFddfdbfddfbdfddFddfdb" 6 | "fddfbdfddFddfdbfddfbdfddF" 7 | "ddfdbfddfbdfddFddfdbfddfb"]) 8 | { 9 | case 'd': printf("%d\n", i); break; 10 | case 'f': puts("Fizz"); break; 11 | case 'b': puts("Buzz"); break; 12 | case 'F': puts("FizzBuzz"); break; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fizzbuzz084.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | const char *format[] = { 5 | "FizzBuzz\n", "%d\n", "%d\n", 6 | "Fizz\n", "%d\n", "Buzz\n", 7 | "Fizz\n", "%d\n", "%d\n", 8 | "Fizz\n", "Buzz\n", "%d\n", 9 | "Fizz\n", "%d\n", "%d\n" }; 10 | int i = 1; 11 | switch (i % 15) do { 12 | for (int j = 0; j < 5; j++) { printf(format[i%15], i); i++; } 13 | case 1: 14 | for (int j = 0; j < 10; j++) { printf(format[i%15], i); i++; } 15 | } while(i < 100); 16 | } 17 | -------------------------------------------------------------------------------- /fizzbuzz023.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | char line[100][9]; 5 | for (int i = 1; i <= 100; i ++ ) { 6 | sprintf(line[i-1], "%d", i); 7 | } 8 | for (int i = 3; i <= 100; i += 3) { 9 | strcpy(line[i-1], "Fizz"); 10 | } 11 | for (int i = 5; i <= 100; i += 5) { 12 | strcpy(line[i-1], "Buzz"); 13 | } 14 | for (int i = 15; i <= 100; i += 15) { 15 | strcpy(line[i-1], "FizzBuzz"); 16 | } 17 | for (int i = 1; i <= 100; i ++) { 18 | puts(line[i-1]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fizzbuzz116.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const char *const format = { 4 | "FizzBuzz\n\0" 5 | "Fizz\n\0" 6 | "%d\n" 7 | }; 8 | enum { 9 | FizzBuzz = 0, 10 | Fizz = 10, 11 | Buzz = 4, 12 | num = 16 13 | }; 14 | for (int i = 1; i <= 100; i ++) { 15 | printf(format + (i % 15 == 0 ? FizzBuzz : 16 | i % 3 == 0 ? Fizz : 17 | i % 5 == 0 ? Buzz : 18 | num), 19 | i); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz034.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz (int n) { puts("Fizz"); } 4 | static void buzz (int n) { puts("Buzz"); } 5 | static void fizzbuzz (int n) { puts("FizzBuzz"); } 6 | static void print (int n) { printf("%d\n", n); } 7 | 8 | static void line(int n) { 9 | (!(n%15) ? fizzbuzz : !(n%3) ? fizz : !(n%5) ? buzz : print)(n); 10 | } 11 | 12 | static void loop(int first, int last, void (*func)(int)) { 13 | for (int i = first; i <= last ; i ++) { 14 | func(i); 15 | } 16 | } 17 | 18 | int main(void) { 19 | loop(1, 100, line); 20 | } 21 | -------------------------------------------------------------------------------- /fizzbuzz098.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | FILE **f = 2+(FILE*[6]){ tmpfile(), stdout }; 4 | char *s[] = { "Fizz", "Buzz", (char[3]){0}, "\n" }; 5 | for (int i = 1; i <= 100; i ++) { 6 | s[2][0] = (i < 9 ? i : i/10) + '0'; 7 | s[2][1] = i < 9 ? 0 : i%10 + '0'; 8 | f[0] = f[i % 3 ? -2 : -1]; 9 | f[1] = f[i % 5 ? -2 : -1]; 10 | f[2] = f[f[0] == f[-1] || f[1] == f[-1] ? -2 : -1]; 11 | f[3] = f[-1]; 12 | for (int j = 0; j < 4; j ++) { 13 | fputs(s[j], f[j]); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fizzbuzz080.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | char *lines[100] = { 0 }, nums[162], *cursor = nums; 4 | const struct { char *s; int n; } dat[] = { "Fizz", 3, "Buzz", 5, "FizzBuzz", 15 }; 5 | for (int i = 0; i < 3; i ++) { 6 | for (int j = dat[i].n-1; j < 100; j += dat[i].n) { 7 | lines[j] = dat[i].s; 8 | } 9 | } 10 | for (int i = 0; i < 100; i ++) { 11 | lines[i] || (lines[i] = cursor += 3) && sprintf(lines[i], "%d", i+1); 12 | } 13 | for (int i = 0; i < 100; i ++) { 14 | puts(lines[i]); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fizzbuzz128.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | const struct { int n; const char *s; } table[] = { 5 | { 3, "Fizz" }, 6 | { 5, "Buzz" }, 7 | }; 8 | for (int i = 1; i <= 100; i ++) { 9 | int printed = 0; 10 | for (int j = 0; j < sizeof table / sizeof *table; j ++) { 11 | if (i % table[j].n == 0) { 12 | fputs(table[j].s, stdout); 13 | printed = 1; 14 | } 15 | } 16 | if (!printed) { 17 | printf("%d", i); 18 | } 19 | putchar('\n'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz091.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const unsigned char lines[100] = 4 | "\1\2F\4BF\7\10FB\13F\15\16Z" 5 | "\20\21F\23BF\26\27FB\32F\34\35Z" 6 | "\37 F\"BF%&FB)F+,Z" 7 | "./F1BF45FB8F:;Z" 8 | "=>F@BFCDFBGFIJZ" 9 | "LMFOBFRSFBVFXYZ" 10 | "[\\F^BFabFB"; 11 | for (int i = 0; i < sizeof lines; i ++) { 12 | lines[i] == 'F' && (puts("Fizz")||1ll) || 13 | lines[i] == 'B' && (puts("Buzz")||1ll) || 14 | lines[i] == 'Z' && (puts("FizzBuzz")||1ll) || 15 | printf("%d\n", lines[i]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz112.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IF(cond,le,eq,gt) do { switch(((cond) < 0 ? -1 : (cond) == 0 ? 0 : 1)) \ 4 | { case -1: goto le; case 0: goto eq; case 1: goto gt; } } while (0) 5 | 6 | int main(void) { 7 | int i = 1; 8 | L1: IF (i % 15, L3, L2, L3); 9 | L2: puts("FizzBuzz"); 10 | goto L8; 11 | L3: IF (i % 3, L5, L4, L5); 12 | L4: puts("Fizz"); 13 | goto L8; 14 | L5: IF (i % 5, L7, L6, L7); 15 | L6: puts("Buzz"); 16 | goto L8; 17 | L7: printf("%d\n", i); 18 | L8: i ++; IF (i - 101, L1, L9, L1); 19 | L9:; 20 | } 21 | -------------------------------------------------------------------------------- /fizzbuzz035.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz (int n) { puts("Fizz"); } 4 | static void buzz (int n) { puts("Buzz"); } 5 | static void fizzbuzz (int n) { puts("FizzBuzz"); } 6 | static void print (int n) { printf("%d\n", n); } 7 | 8 | static void line(int n) { 9 | (!(n%15) ? fizzbuzz : !(n%3) ? fizz : !(n%5) ? buzz : print)(n); 10 | } 11 | 12 | static void recurse(int first, int last, void (*func)(int)) { 13 | if (first <= last) { 14 | func(first); 15 | recurse(first+1, last, func); 16 | } 17 | } 18 | 19 | int main(void) { 20 | recurse(1, 100, line); 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz138.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static char s[10] = "FizzBuzzzz"; 4 | 5 | static int span(int i) { 6 | switch (i % 15) { 7 | case 3: case 6: case 9: case 12: return 0x04; 8 | case 5: case 10: return 0x44; 9 | case 0: return 0x08; 10 | default: 11 | s[8] = '0' + i / 10; 12 | s[9] = '0' + i % 10; 13 | if (i < 10) return 0x91; else return 0x82; 14 | } 15 | } 16 | 17 | int main(void) { 18 | for (int i = 1; i <= 100; i ++) { 19 | const int sp = span(i); 20 | printf("%.*s\n", sp & 15, s + (sp >> 4)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz022.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz (int n) { puts("Fizz"); } 4 | static void buzz (int n) { puts("Buzz"); } 5 | static void fizzbuzz (int n) { puts("FizzBuzz"); } 6 | static void print (int n) { printf("%d\n", n); } 7 | 8 | int main(void) { 9 | void (*funcs[15])(int) = { 0 }; 10 | for (int i = 0; i < 15; i += 3) funcs[i] = fizz; 11 | for (int i = 0; i < 15; i += 5) funcs[i] = buzz; 12 | funcs[0] = fizzbuzz; 13 | for (int i = 0; i < 15; i ++) { 14 | if (funcs[i] == NULL) funcs[i] = print; 15 | } 16 | for (int i = 1; i <= 100; i ++) funcs[i%15](i); 17 | } 18 | -------------------------------------------------------------------------------- /fizzbuzz050.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 0; i < 100; i ++) { 4 | switch (i["[[][\"][[]\"[][['" 5 | "[[][\"][[]\"[][['" 6 | "[[][\"][[]\"[][['" 7 | "[[][\"][[]\"[][['" 8 | "[[][\"][[]\"[][['" 9 | "[[][\"][[]\"[][['" 10 | "[[][\"][[]\"[][['"]) 11 | { 12 | case '[': printf("%d\n", i+1); break; 13 | case ']': puts("Fizz"); break; 14 | case '"': puts("Buzz"); break; 15 | case '\'': puts("FizzBuzz"); break; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fizzbuzz012.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz(int n) { 4 | fputs("Fizz", stdout); 5 | } 6 | 7 | static void buzz(int n) { 8 | fputs("Buzz", stdout); 9 | } 10 | 11 | static void print(int n) { 12 | printf("%d", n); 13 | } 14 | 15 | static void nothing(int n) { 16 | } 17 | 18 | static void (*first(int n))(int) { 19 | return !(n%3) ? fizz : nothing; 20 | } 21 | 22 | static void (*second(int n))(int) { 23 | return !(n%5) ? buzz : n%3 ? print : nothing; 24 | } 25 | 26 | int main(void) { 27 | for (int i = 1; i <= 100; i ++) { 28 | first(i)(i); 29 | second(i)(i); 30 | putchar('\n'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /fizzbuzz003.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This version works only if stdout is seekable 3 | */ 4 | #include 5 | #include 6 | #include 7 | int main(void) { 8 | for (int i = 1; i <= 100; i ++) { 9 | long start = ftell(stdout); 10 | if (start == -1L) { 11 | perror("ftell"); 12 | exit(EXIT_FAILURE); 13 | } 14 | if (i % 3 == 0) { 15 | fputs("Fizz", stdout); 16 | } 17 | if (i % 5 == 0) { 18 | fputs("Buzz", stdout); 19 | } 20 | if (ftell(stdout) == start) { 21 | printf("%d", i); 22 | } 23 | putchar('\n'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /fizzbuzz117.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static char *num(int n) { 5 | static char buf[3]; 6 | return sprintf(buf, "%d", n), buf; 7 | } 8 | 9 | int line(int i) { 10 | static const char *const message[] = { 11 | [3] = "Fizz", [6] = "Fizz", [9] = "Fizz", [12] = "Fizz", 12 | [5] = "Buzz", [10] = "Buzz", 13 | [0] = "FizzBuzz", 14 | [14] = NULL, 15 | }; 16 | return i == 101 ? 0 : puts(message[i%15] ? message[i%15] : num(i)); 17 | } 18 | 19 | int fizzbuzz(int n) { 20 | return n == 1 ? line(n) : (fizzbuzz(n-1), line(n)); 21 | } 22 | 23 | int main(void) { 24 | return fizzbuzz(101); 25 | } 26 | -------------------------------------------------------------------------------- /fizzbuzz093.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IF(cond,le,eq,gt) do { switch(((cond) < 0 ? -1 : (cond) == 0 ? 0 : 1)) \ 4 | { case -1: goto le; case 0: goto eq; case 1: goto gt; } } while (0) 5 | 6 | int main(void) { 7 | for (int i = 1; i <= 100; i ++) { 8 | IF (i % 15, L19, L10, L19); 9 | L10: puts("FizzBuzz"); 10 | goto L99; 11 | 12 | L19: IF (i % 3, L29, L20, L29); 13 | L20: puts("Fizz"); 14 | goto L99; 15 | 16 | L29: IF (i % 5, L39, L30, L39); 17 | L30: puts("Buzz"); 18 | goto L99; 19 | 20 | L39: printf("%d\n", i); 21 | 22 | L99:; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /fizzbuzz010.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void fizz (int n) { puts("Fizz"); } 4 | static void buzz (int n) { puts("Buzz"); } 5 | static void fizzbuzz (int n) { puts("FizzBuzz"); } 6 | static void print (int n) { printf("%d\n", n); } 7 | 8 | int main(void) { 9 | void (*funcs[100])(int) = { 0 }; 10 | 11 | for (int i = 3; i <= 100; i += 3) funcs[i-1] = fizz; 12 | for (int i = 5; i <= 100; i += 5) funcs[i-1] = buzz; 13 | for (int i = 15; i <= 100; i += 15) funcs[i-1] = fizzbuzz; 14 | for (int i = 1; i <= 100; i ++) { 15 | if (funcs[i-1] == NULL) funcs[i-1] = print; 16 | } 17 | 18 | for (int i = 1; i <= 100; i ++) funcs[i-1](i); 19 | } 20 | -------------------------------------------------------------------------------- /fizzbuzz136.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define print1(n) \ 4 | ((n) % 15 == 0 ? puts("FizzBuzz") : \ 5 | (n) % 3 == 0 ? puts("Fizz") : \ 6 | (n) % 5 == 0 ? puts("Buzz") : \ 7 | printf("%d\n", (n))) 8 | 9 | #define print5(n) \ 10 | (print1(n), \ 11 | print1(n+1), \ 12 | print1(n+2), \ 13 | print1(n+3), \ 14 | print1(n+4)) 15 | 16 | #define print25(n) \ 17 | (print5(n), \ 18 | print5(n+5), \ 19 | print5(n+10), \ 20 | print5(n+15), \ 21 | print5(n+20)) 22 | 23 | #define print100(n) \ 24 | (print25(n), \ 25 | print25(n+25), \ 26 | print25(n+50), \ 27 | print25(n+75)) 28 | 29 | int main(void) { 30 | print100(1); 31 | } 32 | -------------------------------------------------------------------------------- /fizzbuzz139.c: -------------------------------------------------------------------------------- 1 | extern int putchar(int ch); 2 | 3 | static void putline(const char *s) { 4 | for (const char *p = s; *p != '\0'; p ++) { 5 | putchar(*p); 6 | } 7 | putchar('\n'); 8 | } 9 | 10 | int main(void) { 11 | for (int i = 1; i <= 100; i ++) { 12 | if (i % 15 == 0) { 13 | putline("FizzBuzz"); 14 | } 15 | else if (i % 3 == 0) { 16 | putline("Fizz"); 17 | } 18 | else if (i % 5 == 0) { 19 | putline("Buzz"); 20 | } 21 | else { 22 | if (i >= 10) putchar(i / 10 + '0'); 23 | putchar(i % 10 + '0'); 24 | putchar('\n'); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fizzbuzz004.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | puts("1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\n" 4 | "FizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\n" 5 | "Fizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\n" 6 | "Buzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n" 7 | "53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\n" 8 | "Fizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n" 9 | "79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n" 10 | "92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz" 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /fizzbuzz144.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define define_funcs(x, y, z) \ 4 | static void x(int n) { puts(#x); } \ 5 | static void y(int n) { puts(#y); } \ 6 | static void z(int n) { puts(#z); } 7 | define_funcs(Fizz, Buzz, FizzBuzz) 8 | static void print(int n) { 9 | const char s[3] = {n/10+'0',n%10+'0'}; 10 | puts(s + (n < 10)); 11 | } 12 | static void (*funcs[101])(int); 13 | 14 | static void set(int n, void (*func)(int)) { 15 | for (int i = n; i <= 100; i += n) { 16 | funcs[i] = func; 17 | } 18 | } 19 | 20 | int main(void) { 21 | set(1, print); 22 | set(3, Fizz); 23 | set(5, Buzz); 24 | set(15, FizzBuzz); 25 | for (int i = 1; i <= 100; i ++) funcs[i](i); 26 | } 27 | -------------------------------------------------------------------------------- /fizzbuzz142.c: -------------------------------------------------------------------------------- 1 | #define ONE '/'/'/' 2 | #define ZERO ONE-ONE 3 | #define TWO ONE+ONE 4 | #define THREE ONE+ONE+ONE 5 | #define FIVE TWO+THREE 6 | #define TEN FIVE+FIVE 7 | #define FIFTEEN TEN+FIVE 8 | #define THIRTY FIFTEEN+FIFTEEN 9 | #define ONE_HUNDRED THIRTY+THIRTY+THIRTY+TEN 10 | 11 | #include 12 | int main(void) { 13 | for (int i = ONE; i <= ONE_HUNDRED; i ++) { 14 | if (i % (FIFTEEN) == ZERO) { 15 | puts("FizzBuzz"); 16 | } 17 | else if (i % (THREE) == ZERO) { 18 | puts("Fizz"); 19 | } 20 | else if (i % (FIVE) == ZERO) { 21 | puts("Buzz"); 22 | } 23 | else { 24 | printf("%d\n", i); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fizzbuzz048.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | puts((char[]){ 5 | !(i % 3) * 'F' + 6 | (i % 3 && i % 5 == 0) * 'B' + 7 | (i % 3 && i % 5 && i < 10) * (i + '0') + 8 | (i % 3 && i % 5 && i > 9) * (i / 10 + '0'), 9 | !(i % 3) * 'i' + 10 | (i % 3 && !(i % 5)) * 'u' + 11 | (i % 3 && i % 5 && i >= 10) * (i % 10 + '0'), 12 | (!(i % 3) || !(i % 5)) * 'z', 13 | (!(i % 3) || !(i % 5)) * 'z', 14 | !(i % 15) * 'B', 15 | !(i % 15) * 'u', 16 | !(i % 15) * 'z', 17 | !(i % 15) * 'z', 18 | '\0' 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz122.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | if (puts("1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13" 4 | "\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz" 5 | "\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz" 6 | "\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46" 7 | "\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n" 8 | "58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFi" 9 | "zz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\nBu" 10 | "zz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n" 11 | "91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz")){} 12 | } 13 | -------------------------------------------------------------------------------- /fizzbuzz037.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const char b[] = 4 | " " 5 | " " 6 | " " 7 | " " 8 | " " 9 | " " 10 | " " 11 | " " 12 | " " 13 | " "; 14 | for (int i = 1; i <= 100; i ++) { 15 | switch (2*b[2*i-2] + b[2*i-1]) { 16 | case 3*' ' : printf("%d\n", i); break; 17 | case 2*' '+'\t': puts("Fizz"); break; 18 | case 2*'\t'+' ': puts("Buzz"); break; 19 | case 3*'\t' : puts("FizzBuzz"); break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz066.c: -------------------------------------------------------------------------------- 1 | #define PROGRAM(name) int name(void) 2 | #define MOD % 3 | #define FOR(i, lo, hi) for (int i = lo; i <= hi; i ++) { 4 | #define DO 5 | #define BEGIN { 6 | #define END } 7 | #define IF if ( 8 | #define THEN ) { 9 | #define ELSEIF } else if ( 10 | #define ELSE } else { 11 | #define ENDIF } 12 | #define ENDFOR } 13 | #define PRINT(s) puts(s); 14 | #define PRINTINTEGER(i) printf("%d\n", i); 15 | 16 | #include 17 | 18 | PROGRAM(main) 19 | BEGIN 20 | FOR (I, 1, 100) DO 21 | IF I MOD 15 == 0 THEN 22 | PRINT("FizzBuzz") 23 | ELSEIF I MOD 3 == 0 THEN 24 | PRINT("Fizz") 25 | ELSEIF I MOD 5 == 0 THEN 26 | PRINT("Buzz") 27 | ELSE 28 | PRINTINTEGER(I) 29 | ENDIF 30 | ENDFOR 31 | END 32 | -------------------------------------------------------------------------------- /fizzbuzz090.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | const int lines[] = { 4 | 1, 2, 3, 4, 5, 3, 7, 8, 3, 5, 11, 3, 13, 14, 15, 5 | 16, 17, 3, 19, 5, 3, 22, 23, 3, 5, 26, 3, 28, 29, 15, 6 | 31, 32, 3, 34, 5, 3, 37, 38, 3, 5, 41, 3, 43, 44, 15, 7 | 46, 47, 3, 49, 5, 3, 52, 53, 3, 5, 56, 3, 58, 59, 15, 8 | 61, 62, 3, 64, 5, 3, 67, 68, 3, 5, 71, 3, 73, 74, 15, 9 | 76, 77, 3, 79, 5, 3, 82, 83, 3, 5, 86, 3, 88, 89, 15, 10 | 91, 92, 3, 94, 5, 3, 97, 98, 3, 5 11 | }; 12 | for (int i = 0; i < 100; i ++) { 13 | lines[i] == 3 && (puts("Fizz")||1ll) || 14 | lines[i] == 5 && (puts("Buzz")||1ll) || 15 | lines[i] == 15 && (puts("FizzBuzz")||1ll) || 16 | printf("%d\n", lines[i]); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fizzbuzz026.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int x = 0; x <= 10; x ++) { 4 | for (int y = 0; y <= 9; y ++) { 5 | if (x == 0 && y == 0) { 6 | continue; 7 | } 8 | int printed = 0; 9 | if ((x + y) % 3 == 0) { 10 | fputs("Fizz", stdout); 11 | printed = 1; 12 | } 13 | if (y == 0 || y == 5) { 14 | fputs("Buzz", stdout); 15 | printed = 1; 16 | } 17 | if (!printed) { 18 | x && printf("%d", x); 19 | y && putchar(y%10 + '0') || putchar('0'); 20 | } 21 | putchar('\n'); 22 | if (x == 10 && y == 0) { 23 | break; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fizzbuzz049.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define PUTCHAR(c) (((c) ? putchar : isdigit)(c)) 4 | int main(void) { 5 | for (int i = 1; i <= 100; i ++) { 6 | PUTCHAR(!(i % 3) * 'F' | 7 | (i % 3 && i % 5 == 0) * 'B' | 8 | (i % 3 && i % 5 && i < 10) * (i + '0') | 9 | (i % 3 && i % 5 && i > 9) * (i / 10 + '0')); 10 | PUTCHAR(!(i % 3) * 'i' | 11 | (i % 3 && !(i % 5)) * 'u' | 12 | (i % 3 && i % 5 && i >= 10) * (i % 10 + '0')); 13 | PUTCHAR((!(i % 3) || !(i % 5)) * 'z'); 14 | PUTCHAR((!(i % 3) || !(i % 5)) * 'z'); 15 | PUTCHAR(!(i % 15) * 'B'); 16 | PUTCHAR(!(i % 15) * 'u'); 17 | PUTCHAR(!(i % 15) * 'z'); 18 | PUTCHAR(!(i % 15) * 'z'); 19 | PUTCHAR('\n'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz047.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | char line[9]; 5 | line[0] = (i % 3 == 0 ? 'F' : 6 | i % 5 == 0 ? 'B' : 7 | i < 10 ? i + '0' : 8 | i / 10 + '0'); 9 | line[1] = (i % 3 == 0 ? 'i' : 10 | i % 5 == 0 ? 'u' : 11 | i < 10 ? '\0' : 12 | i % 10 + '0'); 13 | line[2] = (i % 3 == 0 || i % 5 == 0 ? 'z' : '\0'); 14 | line[3] = (i % 3 == 0 || i % 5 == 0 ? 'z' : '\0'); 15 | line[4] = (i % 15 == 0 ? 'B' : '\0'); 16 | line[5] = (i % 15 == 0 ? 'u' : '\0'); 17 | line[6] = (i % 15 == 0 ? 'z' : '\0'); 18 | line[7] = (i % 15 == 0 ? 'z' : '\0'); 19 | line[8] = '\0'; 20 | puts(line); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz056.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int i = 1; 5 | goto s11; 6 | s00: puts("FizzBuzz"); i++; goto s11; 7 | s01: puts("Fizz"); i++; goto s12; 8 | s02: puts("Fizz"); i++; goto s13; 9 | s03: puts("Fizz"); i++; goto s14; 10 | s04: puts("Fizz"); i++; goto s10; 11 | s10: puts("Buzz"); i++; if (i > 100) goto s99; goto s21; 12 | s11: printf("%d\n", i++); goto s22; 13 | s12: printf("%d\n", i++); goto s23; 14 | s13: printf("%d\n", i++); goto s24; 15 | s14: printf("%d\n", i++); goto s20; 16 | s20: puts("Buzz"); i++; goto s01; 17 | s21: printf("%d\n", i++); goto s02; 18 | s22: printf("%d\n", i++); goto s03; 19 | s23: printf("%d\n", i++); goto s04; 20 | s24: printf("%d\n", i++); goto s00; 21 | s99:; 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz057.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int i = 1; 5 | goto l7; 6 | l8: printf("Fizz\n", i++); goto l1; 7 | l6: printf("Fizz\n", i++); goto l2; 8 | l9: printf("%d\n", i++); goto l8; 9 | lf: printf("%d\n", i++); goto l6; 10 | lc: printf("Fizz\n", i++); goto l0; 11 | la: printf("Buzz\n", i++); if (i > 100) goto l4; goto lf; 12 | l7: printf("%d\n", i++); goto l9; 13 | l2: printf("%d\n", i++); goto l3; 14 | l0: printf("%d\n", i++); goto l5; 15 | lb: printf("FizzBuzz\n", i++); goto l7; 16 | le: printf("Buzz\n", i++); goto lc; 17 | l3: printf("%d\n", i++); goto lb; 18 | l1: printf("%d\n", i++); goto le; 19 | ld: printf("Fizz\n", i++); goto la; 20 | l5: printf("%d\n", i++); goto ld; 21 | l4:; 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz141.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) { 6 | char *lines[101] = { 0 }; 7 | srand(time(NULL)); 8 | int count = 0; 9 | while (count < 100) { 10 | const int i = rand() % 100 + 1; 11 | if (lines[i] == NULL) { 12 | if (i % 15 == 0) { 13 | lines[i] = "FizzBuzz"; 14 | } 15 | else if (i % 3 == 0) { 16 | lines[i] = "Fizz"; 17 | } 18 | else if (i % 5 == 0) { 19 | lines[i] = "Buzz"; 20 | } 21 | else { 22 | lines[i] = malloc(3); 23 | sprintf(lines[i], "%d", i); 24 | } 25 | count ++; 26 | } 27 | } 28 | for (int i = 1; i < sizeof lines / sizeof lines[0]; i ++) { 29 | puts(lines[i]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fizzbuzz020.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | int i = 1; 4 | switch (i % 15) { 5 | case 11: do { printf("%d\n", i++); 6 | case 12: puts("Fizz"); i++; 7 | case 13: printf("%d\n", i++); 8 | case 14: printf("%d\n", i++); 9 | case 0: puts("FizzBuzz"); i++; 10 | case 1: printf("%d\n", i++); 11 | case 2: printf("%d\n", i++); 12 | case 3: puts("Fizz"); i++; 13 | case 4: printf("%d\n", i++); 14 | case 5: puts("Buzz"); i++; 15 | case 6: puts("Fizz"); i++; 16 | case 7: printf("%d\n", i++); 17 | case 8: printf("%d\n", i++); 18 | case 9: puts("Fizz"); i++; 19 | case 10: puts("Buzz"); i++; 20 | } while(i < 100); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz126.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | jmp_buf jb[7]; 5 | volatile int j = 0; 6 | setjmp(jb[0]); 7 | volatile int i = 1; 8 | if (!j) setjmp(jb[1]); 9 | j && i > 100 && (longjmp(jb[6], 0), 0); 10 | j && !(i % 15) && (longjmp(jb[4], 0), 0); 11 | j && !(i % 3) && (longjmp(jb[2], 0), 0); 12 | j && !(i % 5) && (longjmp(jb[3], 0), 0); 13 | j && printf("%d\n", i); 14 | j && (longjmp(jb[5], 0), 0); 15 | if (!j) setjmp(jb[2]); 16 | j && puts("Fizz"); 17 | j && (longjmp(jb[5], 0), 0); 18 | if (!j) setjmp(jb[3]); 19 | j && puts("Buzz"); 20 | j && (longjmp(jb[5], 0), 0); 21 | if (!j) setjmp(jb[4]); 22 | j && puts("FizzBuzz"); 23 | if (!j) setjmp(jb[5]); 24 | i ++; 25 | j && (longjmp(jb[1], 0), 0); 26 | if (!j) setjmp(jb[6]); 27 | j++ < 1 && (longjmp(jb[0], 0), 0); 28 | } 29 | -------------------------------------------------------------------------------- /fizzbuzz040.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(int argc, char **argv) { 4 | switch (argc) { 5 | case 1: { 6 | return main(argc+1, (char *[]){argv[0], (char[]){"\x1\x64"}}); 7 | } 8 | case 2: { 9 | const char lo = argv[1][0]; 10 | const char hi = argv[1][1]; 11 | if (lo % 15 == 0) puts("FizzBuzz"); 12 | else if (lo % 3 == 0) puts("Fizz"); 13 | else if (lo % 5 == 0) puts("Buzz"); 14 | else printf("%d\n", lo); 15 | if (lo < hi) { 16 | argv[1][0]++; 17 | return main(argc, argv); 18 | } 19 | else { 20 | return 0; 21 | } 22 | } 23 | default: { 24 | fputs("Usage: %s [range]\n", stderr); 25 | exit(EXIT_FAILURE); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /fizzbuzz081.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void); 4 | 5 | static const char *m() { 6 | for (char c = 0, *p = (char*)main;;) { 7 | if (c++>2) return p; 8 | c*=*p++=='@'; 9 | } 10 | } 11 | 12 | int main(void) { 13 | static const char s[] = 14 | "@@@1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\n" 15 | "FizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\n" 16 | "Fizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\n" 17 | "Buzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n" 18 | "53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\n" 19 | "Fizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n" 20 | "79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n" 21 | "92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz"; 22 | puts(m()); 23 | } 24 | -------------------------------------------------------------------------------- /fizzbuzz119.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static double polynomial(long long n) { 5 | return - 4.956564401E-6 * pow(n, 10) 6 | + 3.717551624E-4 * pow(n, 9) 7 | - 1.204679872E-2 * pow(n, 8) 8 | + 2.209286235E-1 * pow(n, 7) 9 | - 2.52332041 * pow(n, 6) 10 | + 18.61544946 * pow(n, 5) 11 | - 89.05106853 * pow(n, 4) 12 | + 269.9378432 * pow(n, 3) 13 | - 489.974344 * pow(n, 2) 14 | + 472.8329881 * n 15 | - 178.0520294; 16 | } 17 | 18 | int main(void) { 19 | for (int i = 1; i <= 100; i ++) { 20 | switch ((int)round(polynomial(i%15))) { 21 | case -178: puts("FizzBuzz"); break; 22 | case 0: puts("Buzz"); break; 23 | case 1: puts("Fizz"); break; 24 | case 2: printf("%d\n", i); break; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fizzbuzz070.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | int i = 1; 4 | switch (i % 15) { 5 | case 11: do { printf("%d\n", i++); 6 | case 14: printf("Fizz\n", i++); 7 | case 5: printf("%d\n", i++); 8 | case 15: printf("%d\n", i++); 9 | case 4: printf("FizzBuzz\n", i++); 10 | case 1: printf("%d\n", i++); 11 | case 12: printf("%d\n", i++); 12 | case 2: printf("Fizz\n", i++); 13 | case 6: printf("%d\n", i++); 14 | case 3: printf("Buzz\n", i++); 15 | case 10: printf("Fizz\n", i++); 16 | case 7: printf("%d\n", i++); 17 | case 13: printf("%d\n", i++); 18 | case 8: printf("Fizz\n", i++); 19 | case 9: printf("Buzz\n", i++); 20 | } while(i < 100); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz094.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | jmp_buf jb[7]; 5 | volatile int j = 0; 6 | setjmp(jb[0]); 7 | volatile int i = 1; 8 | if (j == 0) setjmp(jb[1]); 9 | if (j == 1 && i > 100) longjmp(jb[6], 0); 10 | if (j == 1 && i % 15 == 0) longjmp(jb[4], 0); 11 | if (j == 1 && i % 3 == 0) longjmp(jb[2], 0); 12 | if (j == 1 && i % 5 == 0) longjmp(jb[3], 0); 13 | if (j == 1) printf("%d\n", i); 14 | if (j == 1) longjmp(jb[5], 0); 15 | if (j == 0) setjmp(jb[2]); 16 | if (j == 1) puts("Fizz"); 17 | if (j == 1) longjmp(jb[5], 0); 18 | if (j == 0) setjmp(jb[3]); 19 | if (j == 1) puts("Buzz"); 20 | if (j == 1) longjmp(jb[5], 0); 21 | if (j == 0) setjmp(jb[4]); 22 | if (j == 1) puts("FizzBuzz"); 23 | if (j == 0) setjmp(jb[5]); 24 | i ++; 25 | if (j == 1) longjmp(jb[1], 0); 26 | if (j == 0) setjmp(jb[6]); 27 | j ++; 28 | if (j < 2) longjmp(jb[0], 0); 29 | } 30 | -------------------------------------------------------------------------------- /fizzbuzz060.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | enum { 4 | k, o, h, n, 5 | e, c, l, g, 6 | a, b, d, p, 7 | m, f, i, j, 8 | }; 9 | const struct format { 10 | const char *format; 11 | int next; 12 | } *format = (struct format[]) { 13 | [h] = { "Fizz\n", +d }, 14 | [d] = { "Fizz\n", +c }, 15 | [n] = { "%d\n", +p }, 16 | [o] = { "%d\n", +e }, 17 | [l] = { "Buzz\n", +o }, 18 | [i] = { "%d\n", -e }, 19 | [g] = { "Fizz\n", -l }, 20 | [j] = { "%d\n", -b }, 21 | [p] = { "FizzBuzz\n", -a }, 22 | [b] = { "%d\n", -g }, 23 | [e] = { "%d\n", +g }, 24 | [m] = { "%d\n", -a }, 25 | [a] = { "Buzz\n", +o }, 26 | [c] = { "%d\n", -c }, 27 | [k] = { "Fizz\n", +a }, 28 | }+n; 29 | for (int i = 1; i <= 100; i ++) { 30 | printf(format->format, i); 31 | format += format->next; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fizzbuzz039.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(int argc, char **argv) { 4 | switch (argc) { 5 | case 1: { 6 | return main(3, (char *[]){ argv[0], "1", "100" }); 7 | } 8 | case 3: { 9 | const int lo = atoi(argv[1]); 10 | const int hi = atoi(argv[2]); 11 | if (lo % 15 == 0) puts("FizzBuzz"); 12 | else if (lo % 3 == 0) puts("Fizz"); 13 | else if (lo % 5 == 0) puts("Buzz"); 14 | else printf("%d\n", lo); 15 | if (lo < hi) { 16 | char arg1[4]; 17 | sprintf(arg1, "%d", lo+1); 18 | return main(3, (char*[]){argv[0], arg1, argv[2]}); 19 | } 20 | else { 21 | return 0; 22 | } 23 | } 24 | default: { 25 | fputs("Usage: %s [lo hi]\n", stderr); 26 | exit(EXIT_FAILURE); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fizzbuzz059.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | enum { 4 | k, o, h, n, 5 | e, c, l, g, 6 | a, b, d, p, 7 | m, f, i, j, 8 | }; 9 | const struct format { 10 | const char *format; 11 | int next; 12 | } *format = (struct format[]) { 13 | [l] = { "Buzz\n", g }, 14 | [h] = { "Fizz\n", m }, 15 | [e] = { "%d\n", p }, 16 | [b] = { "%d\n", h }, 17 | [p] = { "FizzBuzz\n", n }, 18 | [k] = { "Fizz\n", a }, 19 | [c] = { "%d\n", k }, 20 | [d] = { "Fizz\n", j }, 21 | [m] = { "%d\n", e }, 22 | [o] = { "%d\n", c }, 23 | [g] = { "Fizz\n", o }, 24 | [j] = { "%d\n", l }, 25 | [n] = { "%d\n", i }, 26 | [i] = { "%d\n", d }, 27 | [a] = { "Buzz\n", b }, 28 | }+n, *formats=format-n; 29 | for (int i = 1; i <= 100; i ++) { 30 | printf(format->format, i); 31 | format = formats+format->next; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fizzbuzz063.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define MOD15(n) \ 4 | (((n)%15)[(char*[]){ \ 5 | 0, "1", "deux", "drei", "quatro", \ 6 | "kvin", "VI", "sedam", "tmienja", "bederatzi", \ 7 | "tio", "labing-isa", "dodici", "nantathu", "many", \ 8 | }]) 9 | 10 | int main(void) { 11 | for (int i = 1; i <= 100; i ++) { 12 | if (MOD15(i) == 0) { 13 | puts("FizzBuzz"); 14 | } 15 | else if (MOD15(i) == "drei" || 16 | MOD15(i) == "VI" || 17 | MOD15(i) == "bederatzi" || 18 | MOD15(i) == "dodici") 19 | { 20 | puts("Fizz"); 21 | } 22 | else if (MOD15(i) == "kvin" || 23 | MOD15(i) == "tio") 24 | { 25 | puts("Buzz"); 26 | } 27 | else { 28 | printf("%d\n", i); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /expected-output.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | Fizz 4 | 4 5 | Buzz 6 | Fizz 7 | 7 8 | 8 9 | Fizz 10 | Buzz 11 | 11 12 | Fizz 13 | 13 14 | 14 15 | FizzBuzz 16 | 16 17 | 17 18 | Fizz 19 | 19 20 | Buzz 21 | Fizz 22 | 22 23 | 23 24 | Fizz 25 | Buzz 26 | 26 27 | Fizz 28 | 28 29 | 29 30 | FizzBuzz 31 | 31 32 | 32 33 | Fizz 34 | 34 35 | Buzz 36 | Fizz 37 | 37 38 | 38 39 | Fizz 40 | Buzz 41 | 41 42 | Fizz 43 | 43 44 | 44 45 | FizzBuzz 46 | 46 47 | 47 48 | Fizz 49 | 49 50 | Buzz 51 | Fizz 52 | 52 53 | 53 54 | Fizz 55 | Buzz 56 | 56 57 | Fizz 58 | 58 59 | 59 60 | FizzBuzz 61 | 61 62 | 62 63 | Fizz 64 | 64 65 | Buzz 66 | Fizz 67 | 67 68 | 68 69 | Fizz 70 | Buzz 71 | 71 72 | Fizz 73 | 73 74 | 74 75 | FizzBuzz 76 | 76 77 | 77 78 | Fizz 79 | 79 80 | Buzz 81 | Fizz 82 | 82 83 | 83 84 | Fizz 85 | Buzz 86 | 86 87 | Fizz 88 | 88 89 | 89 90 | FizzBuzz 91 | 91 92 | 92 93 | Fizz 94 | 94 95 | Buzz 96 | Fizz 97 | 97 98 | 98 99 | Fizz 100 | Buzz 101 | -------------------------------------------------------------------------------- /fizzbuzz146.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int Break = 15, i = 1; i <= 100; i ++) { 4 | switch (i % Break) { 5 | case 3: Break; 6 | case 6: Break; 7 | case 9: Break; 8 | case 12: fputs("Fizz", stdout); Break; 9 | case 15: putchar('\n'); break; 10 | case 5: Break; 11 | case 10: fputs("Buzz", stdout); Break; 12 | case 0x15: putchar('\n'); break; 13 | case 0: fputs("FizzBuzz", stdout); Break; 14 | case ~15: putchar('\n'); break; 15 | case 1: Break; 16 | case 2: Break; 17 | case 4: Break; 18 | case 7: Break; 19 | case 8: Break; 20 | case 11: Break; 21 | case 13: Break; 22 | case 14: printf("%d", i); Break; 23 | Default: putchar('\n'); break; 24 | default: putchar('\n'); Break; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fizzbuzz055.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | enum state { 5 | s00, s01, s02, s03, s04, 6 | s10, s11, s12, s13, s14, 7 | s20, s21, s22, s23, s24, 8 | end 9 | }; 10 | const enum state next[] = { 11 | s11, s12, s13, s14, s10, 12 | s21, s22, s23, s24, s20, 13 | s01, s02, s03, s04, s00 14 | }; 15 | enum state state = s11; 16 | int i = 1; 17 | 18 | while (state != end) { 19 | switch (state) { 20 | case s01: case s02: case s03: case s04: 21 | puts("Fizz"); 22 | break; 23 | case s10: case s20: 24 | puts("Buzz"); 25 | break; 26 | case s00: 27 | puts("FizzBuzz"); 28 | break; 29 | default: 30 | printf("%d\n", i); 31 | break; 32 | } 33 | i++; 34 | if (i > 100) { 35 | state = end; 36 | } 37 | else { 38 | state = next[state]; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /fizzbuzz058.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | enum { a=012, b, c, d, e, f }; 4 | struct format { 5 | const char *format; 6 | struct format *next; 7 | } formats[] = { 8 | [1] = { "Fizz\n", formats+6 }, 9 | [d] = { "Fizz\n", formats+3 }, 10 | [8] = { "%d\n", formats+c }, 11 | [2] = { "%d\n", formats+d }, 12 | [7] = { "%d\n", formats+2 }, 13 | [b] = { "%d\n", formats+1 }, 14 | [9] = { "FizzBuzz\n", formats+7 }, 15 | [e] = { "%d\n", formats+9 }, 16 | [a] = { "Buzz\n", formats+b }, 17 | [4] = { "Fizz\n", formats+a }, 18 | [5] = { "Buzz\n", formats+0 }, 19 | [0] = { "Fizz\n", formats+8 }, 20 | [3] = { "%d\n", formats+5 }, 21 | [6] = { "%d\n", formats+e }, 22 | [c] = { "%d\n", formats+4 }, 23 | }; 24 | struct format *format = formats+7; 25 | for (int i = 1; i <= 100; i ++) { 26 | printf(format->format, i); 27 | format = format->next; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fizzbuzz076.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const char *value = 5 | "1758144650379409115973060067754372904053986902007805006121152086" 6 | "7346572077350868429529811236342631766865555486625388403294134313" 7 | "9919473464862692563656335862646335991330635579740476402754664709" 8 | "5009452126721282861298586050932151536724800069846116487584481144" 9 | "9718051799587767879877254349622241483186025304973052404751236318" 10 | "3354034918187088400879551859852645138073866199388826076199077845" 11 | "1658923923900956024185490128998052143014495305050258233159568236" 12 | "72202738763385595638676791798247890609"; 13 | 14 | static void print(mpz_t i) { 15 | if (mpz_cmp_si(i, 0) > 0) { 16 | static const char chars[15] = "Fiuz123456789B\n"; 17 | mpz_t q; mpz_init(q); 18 | mpz_t r; mpz_init(r); 19 | mpz_tdiv_qr_ui(q, r, i, 15); 20 | print(q); 21 | putchar(chars[mpz_get_si(r)]); 22 | } 23 | } 24 | 25 | int main(void) { 26 | mpz_t num; 27 | mpz_init_set_str(num, value, 10); 28 | print(num); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /fizzbuzz071.c: -------------------------------------------------------------------------------- 1 | #define BEGIN { 2 | #define BUZZ "Buzz" 3 | #define DO 4 | #define ELSE );} else { 5 | #define ELSEIF );} else if ( 6 | #define END } 7 | #define ENDFOR } 8 | #define ENDIF );} 9 | #define EQUALS == 10 | #define FIFTEEN 15 11 | #define FIVE 5 12 | #define FIZZ "Fizz" 13 | #define FIZZBUZZ "FizzBuzz" 14 | #define FIZZBUZZ71 main 15 | #define FOR(i, lo, hi) for (int i = lo; i <= hi; i ++) { 16 | #define HUNDRED *0144 17 | #define IF if ( 18 | #define IS (void) 19 | #define MOD % 20 | #define ONE 1 21 | #define PRINT puts( 22 | #define PRINTINTEGER printf("%d\n", 23 | #define PROGRAM int 24 | #define THEN ) { 25 | #define THREE 3 26 | #define ZERO 0 27 | #define STANDARD_INPUT_OUTPUT 28 | 29 | #include STANDARD_INPUT_OUTPUT 30 | 31 | PROGRAM FIZZBUZZ71 IS 32 | BEGIN 33 | FOR (I, ONE, ONE HUNDRED) DO 34 | IF I MOD FIFTEEN EQUALS ZERO THEN 35 | PRINT FIZZBUZZ 36 | ELSEIF I MOD THREE EQUALS ZERO THEN 37 | PRINT FIZZ 38 | ELSEIF I MOD FIVE EQUALS ZERO THEN 39 | PRINT BUZZ 40 | ELSE 41 | PRINTINTEGER I 42 | ENDIF 43 | ENDFOR 44 | END 45 | -------------------------------------------------------------------------------- /fizzbuzz021.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | const char *format[] = { 5 | "FizzBuzz\n", "%d\n", "%d\n", 6 | "Fizz\n", "%d\n", "Buzz\n", 7 | "Fizz\n", "%d\n", "%d\n", 8 | "Fizz\n", "Buzz\n", "%d\n", 9 | "Fizz\n", "%d\n", "%d\n" }; 10 | int i = 1; 11 | switch (i % 15) { 12 | case 11: do { printf(format[i%15], i); i++; 13 | case 12: printf(format[i%15], i); i++; 14 | case 13: printf(format[i%15], i); i++; 15 | case 14: printf(format[i%15], i); i++; 16 | case 0: printf(format[i%15], i); i++; 17 | case 1: printf(format[i%15], i); i++; 18 | case 2: printf(format[i%15], i); i++; 19 | case 3: printf(format[i%15], i); i++; 20 | case 4: printf(format[i%15], i); i++; 21 | case 5: printf(format[i%15], i); i++; 22 | case 6: printf(format[i%15], i); i++; 23 | case 7: printf(format[i%15], i); i++; 24 | case 8: printf(format[i%15], i); i++; 25 | case 9: printf(format[i%15], i); i++; 26 | case 10: printf(format[i%15], i); i++; 27 | } while(i < 100); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /fizzbuzz135.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | const char *const F = "FizzBuzz\n", 6 | *const f = "Fizz\n", 7 | *const b = "Buzz\n", 8 | *const d = "%d\n", 9 | *format[105] = {F,d,d,f,d,b,f,d,d,f,b,d,f,d,d}; 10 | for (const char **f = format+15; f < format+100; f+=15) { 11 | memcpy(f, f-15, 15*sizeof*format); 12 | } 13 | 14 | int i = 1; 15 | switch (i % 15) { 16 | case 11: do { printf(format[i], i); i++; 17 | case 12: printf(format[i], i); i++; 18 | case 13: printf(format[i], i); i++; 19 | case 14: printf(format[i], i); i++; 20 | case 0: printf(format[i], i); i++; 21 | case 1: printf(format[i], i); i++; 22 | case 2: printf(format[i], i); i++; 23 | case 3: printf(format[i], i); i++; 24 | case 4: printf(format[i], i); i++; 25 | case 5: printf(format[i], i); i++; 26 | case 6: printf(format[i], i); i++; 27 | case 7: printf(format[i], i); i++; 28 | case 8: printf(format[i], i); i++; 29 | case 9: printf(format[i], i); i++; 30 | case 10: printf(format[i], i); i++; 31 | } while(i < 100); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fizzbuzz079.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | printf("%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%s\n%d\n%s\n%d\n%d\n%" 4 | "s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%s\n%d\n%s\n%d\n%" 5 | "d\n%s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%s\n%d\n%s\n%" 6 | "d\n%d\n%s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%s\n%d\n%" 7 | "s\n%d\n%d\n%s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%s\n%" 8 | "d\n%s\n%d\n%d\n%s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%s\n%" 9 | "s\n%d\n%s\n%d\n%d\n%s\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%" 10 | "s\n%s\n", 1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", 11 | "Buzz", 11, "Fizz", 13, 14, "FizzBuzz", 16, 17, "Fizz", 19, 12 | "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26, "Fizz", 28, 29, 13 | "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38, 14 | "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, 15 | "Fizz", 49, "Buzz", "Fizz", 52, 53, "Fizz", "Buzz", 56, 16 | "Fizz", 58, 59, "FizzBuzz", 61, 62, "Fizz", 64, "Buzz", 17 | "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74, 18 | "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, 19 | "Fizz", "Buzz", 86, "Fizz", 88, 89, "FizzBuzz", 91, 92, 20 | "Fizz", 94, "Buzz", "Fizz", 97, 98, "Fizz", "Buzz"); 21 | } 22 | -------------------------------------------------------------------------------- /fizzbuzz105.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int is_correct(int i, char *line) { 7 | if (i % 15 == 0) { 8 | return strcmp(line, "FizzBuzz") == 0; 9 | } 10 | else if (i % 3 == 0) { 11 | return strcmp(line, "Fizz") == 0; 12 | } 13 | else if (i % 5 == 0) { 14 | return strcmp(line, "Buzz") == 0; 15 | } 16 | else { 17 | char correct[5]; 18 | sprintf(correct, "%d", i); 19 | return strcmp(line, correct) == 0; 20 | } 21 | } 22 | 23 | int main(void) { 24 | char output[100][9]; 25 | int count = 0; 26 | while (count < 100) { 27 | for (int i = 1; i <= 100; i ++) { 28 | if (! is_correct(i, output[i-1])) { 29 | switch (rand() % 4) { 30 | case 0: 31 | strcpy(output[i-1], "FizzBuzz"); 32 | break; 33 | case 1: 34 | strcpy(output[i-1], "Fizz"); 35 | break; 36 | case 2: 37 | strcpy(output[i-1], "Buzz"); 38 | break; 39 | case 3: 40 | sprintf(output[i-1], "%d", i); 41 | break; 42 | } 43 | if (is_correct(i, output[i-1])) { 44 | count ++; 45 | } 46 | } 47 | } 48 | } 49 | for (int i = 1; i <= 100; i ++) { 50 | puts(output[i-1]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fizzbuzz068.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 199309L 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int lines_printed = 0; 9 | static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 10 | 11 | static void try(int status) { 12 | if (status != 0) { 13 | exit(EXIT_FAILURE); 14 | } 15 | } 16 | 17 | static void *thread_routine(void *arg) { 18 | const int i = *(int*)arg; 19 | while (1) { 20 | try(pthread_mutex_lock(&mutex)); 21 | if (lines_printed == i - 1) { 22 | if (i % 15 == 0) puts("FizzBuzz"); 23 | else if (i % 3 == 0) puts("Fizz"); 24 | else if (i % 5 == 0) puts("Buzz"); 25 | else printf("%d\n", i); 26 | lines_printed ++; 27 | free(arg); 28 | try(pthread_mutex_unlock(&mutex)); 29 | pthread_exit(NULL); 30 | } 31 | else { 32 | try(pthread_mutex_unlock(&mutex)); 33 | } 34 | sched_yield(); 35 | } 36 | } 37 | 38 | static void launch_thread(int i, pthread_t *thread) { 39 | int *iptr = malloc(sizeof *iptr); 40 | if (iptr == NULL) { 41 | exit(EXIT_FAILURE); 42 | } 43 | *iptr = i; 44 | try(pthread_create(thread, NULL, thread_routine, iptr)); 45 | } 46 | 47 | int main(void) { 48 | pthread_t threads[100]; 49 | for (int i = 100; i >= 1; i --) { 50 | launch_thread(i, &threads[i-1]); 51 | } 52 | for (int i = 1; i <= 100; i ++) { 53 | try(pthread_join(threads[i-1], NULL)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /fizzbuzz113.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static struct stack_frame { 4 | int lo; 5 | int hi; 6 | enum return_target { zero, one, two } ret; 7 | } stack[8]; 8 | static int sp = -1; 9 | 10 | #define CALL(target, lo_, hi_, ret_) \ 11 | do { \ 12 | sp ++; \ 13 | stack[sp].lo = lo_; \ 14 | stack[sp].hi = hi_; \ 15 | stack[sp].ret = ret_; \ 16 | goto target; \ 17 | } while (0) 18 | 19 | #define RETURN \ 20 | do { \ 21 | const enum return_target ret = stack[sp].ret; \ 22 | sp --; \ 23 | switch (ret) { \ 24 | case zero: goto ZERO; \ 25 | case one: goto ONE; \ 26 | case two: goto TWO; \ 27 | } \ 28 | } while (0) 29 | 30 | int main(void) { 31 | CALL(FIZZBUZZ, 1, 100, zero); 32 | ZERO: return 0; 33 | 34 | FIZZBUZZ: 35 | if (stack[sp].lo == stack[sp].hi) { 36 | if (stack[sp].lo % 15 == 0) { 37 | puts("FizzBuzz"); 38 | } 39 | else if (stack[sp].lo % 3 == 0) { 40 | puts("Fizz"); 41 | } 42 | else if (stack[sp].lo % 5 == 0) { 43 | puts("Buzz"); 44 | } 45 | else { 46 | printf("%d\n", stack[sp].lo); 47 | } 48 | } 49 | else { 50 | const int lo1 = stack[sp].lo, hi1 = stack[sp].hi, mid1 = (lo1 + hi1) >> 1; 51 | CALL(FIZZBUZZ, lo1, mid1, one); 52 | ONE:; 53 | const int lo2 = stack[sp].lo, hi2 = stack[sp].hi, mid2 = (lo2 + hi2) >> 1; 54 | CALL(FIZZBUZZ, mid2+1, hi2, two); 55 | TWO:; 56 | } 57 | RETURN; 58 | } 59 | -------------------------------------------------------------------------------- /fizzbuzz133.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct s { 5 | int i; 6 | const char *s; 7 | }; 8 | 9 | #define MILLION 1000000LL 10 | #define BILLION 1000000000LL 11 | 12 | static void msleep(int milliseconds) { 13 | long long nanoseconds = milliseconds * MILLION; 14 | const struct timespec how_long = { 15 | .tv_sec = nanoseconds / BILLION, 16 | .tv_nsec = nanoseconds % BILLION 17 | }; 18 | thrd_sleep(&how_long, NULL); 19 | } 20 | 21 | static int line(void* arg) { 22 | const struct s argument = *(struct s*)arg; 23 | msleep(30 * argument.i); 24 | argument.s ? puts(argument.s) : printf("%d\n", argument.i); 25 | return 0; 26 | } 27 | 28 | int main(void) { 29 | thrd_t threads[100]; 30 | struct s arguments[100]; 31 | 32 | for (int i = 15; i <= 100; i += 15) { 33 | arguments[i-1] = (struct s){.i = i, .s = "FizzBuzz"}; 34 | thrd_create(&threads[i-1], line, &arguments[i-1]); 35 | } 36 | for (int i = 3; i <= 100; i += 3) if (i % 5) { 37 | arguments[i-1] = (struct s){.i = i, .s = "Fizz"}; 38 | thrd_create(&threads[i-1], line, &arguments[i-1]); 39 | } 40 | for (int i = 5; i <= 100; i += 5) if (i % 3) { 41 | arguments[i-1] = (struct s){.i = i, .s = "Buzz"}; 42 | thrd_create(&threads[i-1], line, &arguments[i-1]); 43 | } 44 | for (int i = 1; i <= 100; i ++) if (i % 3 && i % 5) { 45 | arguments[i-1] = (struct s){.i = i, .s = NULL}; 46 | thrd_create(&threads[i-1], line, &arguments[i-1]); 47 | } 48 | 49 | for (int i = 99; i >= 0; i --) { 50 | thrd_join(threads[i], NULL); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fizzbuzz143.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = '/'/'/'; i <= '/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+ 4 | '/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/' 5 | +'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/ 6 | '/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+ 7 | '/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/' 8 | +'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/ 9 | '/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/' 10 | /'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+ 11 | '/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/' 12 | +'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/ 13 | '/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/' 14 | /'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+ 15 | '/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/' 16 | +'/'/'/'+'/'/'/'; i ++) { 17 | if (i % ('/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/' 18 | +'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/' 19 | /'/') == '/'/'/'-'/'/'/') { 20 | puts("FizzBuzz"); 21 | } 22 | else if (i % ('/'/'/'+'/'/'/'+'/'/'/') == '/'/'/'-'/'/'/') { 23 | puts("Fizz"); 24 | } 25 | else if (i % ('/'/'/'+'/'/'/'+'/'/'/'+'/'/'/'+'/'/'/') == '/'/ 26 | '/'-'/'/'/') { 27 | puts("Buzz"); 28 | } 29 | else { 30 | printf("%d\n", i); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fizzbuzz140.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct FizzBuzz { 6 | void *impl; 7 | }; 8 | 9 | struct FizzBuzz newFizzBuzz(int factor1, int factor2, const char *s1, const char *s2, int lo, int hi); 10 | void invoke(struct FizzBuzz fb); 11 | void destroyFizzBuzz(const struct FizzBuzz *fb); 12 | 13 | int main(void) { 14 | const struct FizzBuzz fb = newFizzBuzz(3, 5, "Fizz", "Buzz", 1, 100); 15 | invoke(fb); 16 | destroyFizzBuzz(&fb); 17 | } 18 | 19 | struct impl { 20 | int factor1; 21 | int factor2; 22 | const char *s1; 23 | const char *s2; 24 | int lo; 25 | int hi; 26 | }; 27 | 28 | struct FizzBuzz newFizzBuzz(int factor1, int factor2, const char *s1, const char *s2, int lo, int hi) { 29 | struct impl *impl = malloc(sizeof *impl); 30 | if (impl != NULL) { 31 | impl->factor1 = factor1; 32 | impl->factor2 = factor2; 33 | impl->s1 = s1; 34 | impl->s2 = s2; 35 | impl->lo = lo; 36 | impl->hi = hi; 37 | } 38 | return (struct FizzBuzz){.impl = impl}; 39 | } 40 | 41 | void invoke(struct FizzBuzz fb) { 42 | const struct impl *impl = (struct impl*)fb.impl; 43 | for (int i = impl->lo; i <= impl->hi; i ++) { 44 | bool printed = false; 45 | if (i % impl->factor1 == 0) { 46 | fputs(impl->s1, stdout); 47 | printed = true; 48 | } 49 | if (i % impl->factor2 == 0) { 50 | fputs(impl->s2, stdout); 51 | printed = true; 52 | } 53 | if (!printed) { 54 | printf("%d", i); 55 | } 56 | putchar('\n'); 57 | } 58 | } 59 | 60 | void destroyFizzBuzz(const struct FizzBuzz *fb) { 61 | free(fb->impl); 62 | } 63 | -------------------------------------------------------------------------------- /fizzbuzz087.c: -------------------------------------------------------------------------------- 1 | #define uf { 2 | #define Fb ; 3 | #define ZI int 4 | #define Ff 15 5 | #define Zf "Fizz" 6 | #define ZB ++ 7 | #define UI puts 8 | #define FF 0 9 | #define FZ ( 10 | #define Bz 5 11 | #define FI 0 12 | #define uz ) 13 | #define Zz if 14 | #define UZ else 15 | #define fF if 16 | #define zI i 17 | #define ZF 100 18 | #define uF else 19 | #define IF i 20 | #define zB ) 21 | #define Uf i 22 | #define Iz ) 23 | #define IB <= 24 | #define bu % 25 | #define ub printf 26 | #define UF ; 27 | #define Zu } 28 | #define uu { 29 | #define BI puts 30 | #define ZU i 31 | #define BZ ; 32 | #define Fu ) 33 | #define fz { 34 | #define Uz for 35 | #define fZ ) 36 | #define zf ( 37 | #define FU } 38 | #define FB 0 39 | #define If 3 40 | #define bf void 41 | #define Fz ; 42 | #define bZ 43 | #define UU ; 44 | #define uI { 45 | #define bB "%d\n" 46 | #define BF { 47 | #define ff % 48 | #define zz , 49 | #define zF main 50 | #define bI ( 51 | #define fu ( 52 | #define uB "Buzz" 53 | #define bz } 54 | #define UB i 55 | #define Bb } 56 | #define fB puts 57 | #define Uu == 58 | #define Zb ) 59 | #define bF } 60 | #define IU == 61 | #define Ub i 62 | #define zU ( 63 | #define zu == 64 | #define uZ "FizzBuzz" 65 | #define bU ) 66 | #define Bf ( 67 | #define bb ) 68 | #define zb ( 69 | #define BB } 70 | #define fb = 71 | #define ZZ if 72 | #define Ib { 73 | #define uU else 74 | #define Iu i 75 | #define II ( 76 | #define fU int 77 | #define zZ ( 78 | #define BU ) 79 | #define IZ % 80 | #define fI ; 81 | #define Bu 1 82 | #include bZ 83 | fU zF FZ bf zB uI Uz bI ZI UB 84 | fb Bu fI Iu IB ZF Fz zI ZB BU 85 | uu ZZ II Uf IZ Ff Uu FB fZ Ib 86 | fB fu uZ uz UF bF uU fF Bf ZU 87 | ff If zu FI Iz BF BI zf Zf Fu 88 | BZ Zu UZ Zz zb IF bu Bz IU FF 89 | Zb fz UI zZ uB bb Fb Bb uF uf 90 | ub zU bB zz Ub bU UU BB bz FU 91 | -------------------------------------------------------------------------------- /fizzbuzz027.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 199309L 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static void die(char *message) { 9 | fprintf(stderr, "%s\n", message); 10 | exit(EXIT_FAILURE); 11 | } 12 | 13 | struct dstring { 14 | char *str; 15 | bool allocated; 16 | }; 17 | 18 | static void *thread_routine(void *arg) { 19 | const int i = *(int*)arg; 20 | struct dstring *result = malloc(sizeof *result); 21 | if (result == NULL) { 22 | die("malloc failed"); 23 | } 24 | if (i % 15 == 0) { 25 | *result = (struct dstring){ .str = "FizzBuzz", .allocated = false }; 26 | } 27 | else if (i % 3 == 0) { 28 | *result = (struct dstring){ .str = "Fizz", .allocated = false }; 29 | } 30 | else if (i % 5 == 0) { 31 | *result = (struct dstring){ .str = "Buzz", .allocated = false }; 32 | } 33 | else { 34 | char *str = malloc(4); 35 | if (str == NULL) { 36 | die("malloc failed"); 37 | } 38 | sprintf(str, "%d", i); 39 | *result = (struct dstring){ .str = str, .allocated = true }; 40 | } 41 | return result; 42 | } 43 | 44 | static struct dstring *line(int i) { 45 | pthread_t thr; 46 | int result = pthread_create(&thr, NULL, thread_routine, &i); 47 | if (result != 0) { 48 | die("Error in pthread_create"); 49 | } 50 | void *retval; 51 | result = pthread_join(thr, &retval); 52 | if (result != 0) { 53 | die("Error in pthread_join"); 54 | } 55 | return retval; 56 | } 57 | 58 | int main(void) { 59 | for (int i = 1; i <= 100; i ++) { 60 | struct dstring *dline = line(i); 61 | puts(dline->str); 62 | if (dline->allocated) { 63 | free(dline->str); 64 | } 65 | free(dline); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /fizzbuzz100.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | char line[101][9] = {0}; 4 | for (int i = 0, col = 3, row = 42; i < 909; i ++, col = (col + 5) % 9, row = 1 + ((row-1) + 17) % 100) { 5 | switch (col) { 6 | case 0: 7 | if (row % 3 == 0) { 8 | line[row][col] = 'F'; 9 | } 10 | else if (row % 5 == 0) { 11 | line[row][col] = 'B'; 12 | } 13 | else if (row < 10) { 14 | line[row][col] = '0' + row; 15 | } 16 | else { 17 | line[row][col] = '0' + row / 10; 18 | } 19 | break; 20 | case 1: 21 | if (row % 3 == 0) { 22 | line[row][col] = 'i'; 23 | } 24 | else if (row % 5 == 0) { 25 | line[row][col] = 'u'; 26 | } 27 | else if (row >= 10) { 28 | line[row][col] = '0' + row % 10; 29 | } 30 | break; 31 | case 2: 32 | case 3: 33 | if (row % 3 == 0 || row % 5 == 0) { 34 | line[row][col] = 'z'; 35 | } 36 | break; 37 | case 4: 38 | if (row % 15 == 0) { 39 | line[row][col] = 'B'; 40 | } 41 | break; 42 | case 5: 43 | if (row % 15 == 0) { 44 | line[row][col] = 'u'; 45 | } 46 | break; 47 | case 6: 48 | case 7: 49 | if (row % 15 == 0) { 50 | line[row][col] = 'z'; 51 | } 52 | break; 53 | } 54 | } 55 | for (int i = 1; i <= 100; i ++) { 56 | puts(line[i]); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /fizzbuzz088.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 1; i <= 100; i ++) { 4 | for (int j = 0; j < 9; j ++) { 5 | const char c = 6 | 'F' * (j == 0 && i % 3 == 0) + 7 | 'B' * ((j == 0 && i % 5 == 0 && i % 3 != 0) || (j == 4 && i % 15 == 0)) + 8 | 'i' * (j == 1 && i % 3 == 0) + 9 | 'z' * (((j == 2 || j == 3) && (i % 3 == 0 || i % 5 == 0)) || ((j == 6 || j == 7) && i % 15 == 0)) + 10 | 'u' * ((j == 1 && i % 5 == 0 && i % 3 != 0) || (j == 5 && i % 15 == 0)) + 11 | '1' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 1 || i / 10 == 1)) || (j == 1 && i >= 10 && i % 10 == 1))) + 12 | '2' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 2 || i / 10 == 2)) || (j == 1 && i >= 10 && i % 10 == 2))) + 13 | '3' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 3 || i / 10 == 3)) || (j == 1 && i >= 10 && i % 10 == 3))) + 14 | '4' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 4 || i / 10 == 4)) || (j == 1 && i >= 10 && i % 10 == 4))) + 15 | '5' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 5 || i / 10 == 5)))) + 16 | '6' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 6 || i / 10 == 6)) || (j == 1 && i >= 10 && i % 10 == 6))) + 17 | '7' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 7 || i / 10 == 7)) || (j == 1 && i >= 10 && i % 10 == 7))) + 18 | '8' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 8 || i / 10 == 8)) || (j == 1 && i >= 10 && i % 10 == 8))) + 19 | '9' * (i % 3 != 0 && i % 5 != 0 && ((j == 0 && (i == 9 || i / 10 == 9)) || (j == 1 && i >= 10 && i % 10 == 9))) + 20 | '\n' * ((i % 15 == 0 && j == 8) || (i % 15 != 0 && (i % 3 == 0 || i % 5 == 0) && j == 4) || (i % 3 != 0 && i % 5 != 0 && ((i < 10 && j == 1) || (i >= 10 && j == 2)))); 21 | c && putchar(c); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /fizzbuzz099.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | char line[101][9] = {0}; 4 | for (int col = 0; col < 9; col ++) { 5 | for (int row = 1; row <= 100; row ++) { 6 | switch (col) { 7 | case 0: 8 | if (row % 3 == 0) { 9 | line[row][col] = 'F'; 10 | } 11 | else if (row % 5 == 0) { 12 | line[row][col] = 'B'; 13 | } 14 | else if (row < 10) { 15 | line[row][col] = '0' + row; 16 | } 17 | else { 18 | line[row][col] = '0' + row / 10; 19 | } 20 | break; 21 | case 1: 22 | if (row % 3 == 0) { 23 | line[row][col] = 'i'; 24 | } 25 | else if (row % 5 == 0) { 26 | line[row][col] = 'u'; 27 | } 28 | else if (row >= 10) { 29 | line[row][col] = '0' + row % 10; 30 | } 31 | break; 32 | case 2: 33 | case 3: 34 | if (row % 3 == 0 || row % 5 == 0) { 35 | line[row][col] = 'z'; 36 | } 37 | break; 38 | case 4: 39 | if (row % 15 == 0) { 40 | line[row][col] = 'B'; 41 | } 42 | break; 43 | case 5: 44 | if (row % 15 == 0) { 45 | line[row][col] = 'u'; 46 | } 47 | break; 48 | case 6: 49 | case 7: 50 | if (row % 15 == 0) { 51 | line[row][col] = 'z'; 52 | } 53 | break; 54 | } 55 | } 56 | } 57 | for (int i = 1; i <= 100; i ++) { 58 | puts(line[i]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /fizzbuzz114.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | fputs("\x31\x0a\x32\x0a\x46\x69\x7a\x7a\x0a\x34\x0a\x42\x75\x7a\x7a" 4 | "\x0a\x46\x69\x7a\x7a\x0a\x37\x0a\x38\x0a\x46\x69\x7a\x7a\x0a" 5 | "\x42\x75\x7a\x7a\x0a\x31\x31\x0a\x46\x69\x7a\x7a\x0a\x31\x33" 6 | "\x0a\x31\x34\x0a\x46\x69\x7a\x7a\x42\x75\x7a\x7a\x0a\x31\x36" 7 | "\x0a\x31\x37\x0a\x46\x69\x7a\x7a\x0a\x31\x39\x0a\x42\x75\x7a" 8 | "\x7a\x0a\x46\x69\x7a\x7a\x0a\x32\x32\x0a\x32\x33\x0a\x46\x69" 9 | "\x7a\x7a\x0a\x42\x75\x7a\x7a\x0a\x32\x36\x0a\x46\x69\x7a\x7a" 10 | "\x0a\x32\x38\x0a\x32\x39\x0a\x46\x69\x7a\x7a\x42\x75\x7a\x7a" 11 | "\x0a\x33\x31\x0a\x33\x32\x0a\x46\x69\x7a\x7a\x0a\x33\x34\x0a" 12 | "\x42\x75\x7a\x7a\x0a\x46\x69\x7a\x7a\x0a\x33\x37\x0a\x33\x38" 13 | "\x0a\x46\x69\x7a\x7a\x0a\x42\x75\x7a\x7a\x0a\x34\x31\x0a\x46" 14 | "\x69\x7a\x7a\x0a\x34\x33\x0a\x34\x34\x0a\x46\x69\x7a\x7a\x42" 15 | "\x75\x7a\x7a\x0a\x34\x36\x0a\x34\x37\x0a\x46\x69\x7a\x7a\x0a" 16 | "\x34\x39\x0a\x42\x75\x7a\x7a\x0a\x46\x69\x7a\x7a\x0a\x35\x32" 17 | "\x0a\x35\x33\x0a\x46\x69\x7a\x7a\x0a\x42\x75\x7a\x7a\x0a\x35" 18 | "\x36\x0a\x46\x69\x7a\x7a\x0a\x35\x38\x0a\x35\x39\x0a\x46\x69" 19 | "\x7a\x7a\x42\x75\x7a\x7a\x0a\x36\x31\x0a\x36\x32\x0a\x46\x69" 20 | "\x7a\x7a\x0a\x36\x34\x0a\x42\x75\x7a\x7a\x0a\x46\x69\x7a\x7a" 21 | "\x0a\x36\x37\x0a\x36\x38\x0a\x46\x69\x7a\x7a\x0a\x42\x75\x7a" 22 | "\x7a\x0a\x37\x31\x0a\x46\x69\x7a\x7a\x0a\x37\x33\x0a\x37\x34" 23 | "\x0a\x46\x69\x7a\x7a\x42\x75\x7a\x7a\x0a\x37\x36\x0a\x37\x37" 24 | "\x0a\x46\x69\x7a\x7a\x0a\x37\x39\x0a\x42\x75\x7a\x7a\x0a\x46" 25 | "\x69\x7a\x7a\x0a\x38\x32\x0a\x38\x33\x0a\x46\x69\x7a\x7a\x0a" 26 | "\x42\x75\x7a\x7a\x0a\x38\x36\x0a\x46\x69\x7a\x7a\x0a\x38\x38" 27 | "\x0a\x38\x39\x0a\x46\x69\x7a\x7a\x42\x75\x7a\x7a\x0a\x39\x31" 28 | "\x0a\x39\x32\x0a\x46\x69\x7a\x7a\x0a\x39\x34\x0a\x42\x75\x7a" 29 | "\x7a\x0a\x46\x69\x7a\x7a\x0a\x39\x37\x0a\x39\x38\x0a\x46\x69" 30 | "\x7a\x7a\x0a\x42\x75\x7a\x7a\x0a", stdout); 31 | } 32 | -------------------------------------------------------------------------------- /fizzbuzz089.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (int i = 9; i < 909; i ++) { 4 | char c; 5 | (c = 'F' * (i % 9 == 0 && i / 9 % 3 == 0) + 6 | 'B' * ((i % 9 == 0 && i / 9 % 5 == 0 && i / 9 % 3 != 0) || (i % 9 == 4 && i / 9 % 15 == 0)) + 7 | 'i' * (i % 9 == 1 && i / 9 % 3 == 0) + 8 | 'z' * (((i % 9 == 2 || i % 9 == 3) && (i / 9 % 3 == 0 || i / 9 % 5 == 0)) || ((i % 9 == 6 || i % 9 == 7) && i / 9 % 15 == 0)) + 9 | 'u' * ((i % 9 == 1 && i / 9 % 5 == 0 && i / 9 % 3 != 0) || (i % 9 == 5 && i / 9 % 15 == 0)) + 10 | '1' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 1 || i / 9 / 10 == 1)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 1))) + 11 | '2' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 2 || i / 9 / 10 == 2)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 2))) + 12 | '3' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 3 || i / 9 / 10 == 3)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 3))) + 13 | '4' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 4 || i / 9 / 10 == 4)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 4))) + 14 | '5' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 5 || i / 9 / 10 == 5)))) + 15 | '6' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 6 || i / 9 / 10 == 6)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 6))) + 16 | '7' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 7 || i / 9 / 10 == 7)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 7))) + 17 | '8' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 8 || i / 9 / 10 == 8)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 8))) + 18 | '9' * (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i % 9 == 0 && (i / 9 == 9 || i / 9 / 10 == 9)) || (i % 9 == 1 && i / 9 >= 10 && i / 9 % 10 == 9))) + 19 | '\n' * ((i / 9 % 15 == 0 && i % 9 == 8) || (i / 9 % 15 != 0 && (i / 9 % 3 == 0 || i / 9 % 5 == 0) && i % 9 == 4) || (i / 9 % 3 != 0 && i / 9 % 5 != 0 && ((i / 9 < 10 && i % 9 == 1) || (i / 9 >= 10 && i % 9 == 2))))) 20 | && putchar(c); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fizzbuzz053.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | puts("1"); 4 | puts("2"); 5 | puts("Fizz"); 6 | puts("4"); 7 | puts("Buzz"); 8 | puts("Fizz"); 9 | puts("7"); 10 | puts("8"); 11 | puts("Fizz"); 12 | puts("Buzz"); 13 | puts("11"); 14 | puts("Fizz"); 15 | puts("13"); 16 | puts("14"); 17 | puts("FizzBuzz"); 18 | puts("16"); 19 | puts("17"); 20 | puts("Fizz"); 21 | puts("19"); 22 | puts("Buzz"); 23 | puts("Fizz"); 24 | puts("22"); 25 | puts("23"); 26 | puts("Fizz"); 27 | puts("Buzz"); 28 | puts("26"); 29 | puts("Fizz"); 30 | puts("28"); 31 | puts("29"); 32 | puts("FizzBuzz"); 33 | puts("31"); 34 | puts("32"); 35 | puts("Fizz"); 36 | puts("34"); 37 | puts("Buzz"); 38 | puts("Fizz"); 39 | puts("37"); 40 | puts("38"); 41 | puts("Fizz"); 42 | puts("Buzz"); 43 | puts("41"); 44 | puts("Fizz"); 45 | puts("43"); 46 | puts("44"); 47 | puts("FizzBuzz"); 48 | puts("46"); 49 | puts("47"); 50 | puts("Fizz"); 51 | puts("49"); 52 | puts("Buzz"); 53 | puts("Fizz"); 54 | puts("52"); 55 | puts("53"); 56 | puts("Fizz"); 57 | puts("Buzz"); 58 | puts("56"); 59 | puts("Fizz"); 60 | puts("58"); 61 | puts("59"); 62 | puts("FizzBuzz"); 63 | puts("61"); 64 | puts("62"); 65 | puts("Fizz"); 66 | puts("64"); 67 | puts("Buzz"); 68 | puts("Fizz"); 69 | puts("67"); 70 | puts("68"); 71 | puts("Fizz"); 72 | puts("Buzz"); 73 | puts("71"); 74 | puts("Fizz"); 75 | puts("73"); 76 | puts("74"); 77 | puts("FizzBuzz"); 78 | puts("76"); 79 | puts("77"); 80 | puts("Fizz"); 81 | puts("79"); 82 | puts("Buzz"); 83 | puts("Fizz"); 84 | puts("82"); 85 | puts("83"); 86 | puts("Fizz"); 87 | puts("Buzz"); 88 | puts("86"); 89 | puts("Fizz"); 90 | puts("88"); 91 | puts("89"); 92 | puts("FizzBuzz"); 93 | puts("91"); 94 | puts("92"); 95 | puts("Fizz"); 96 | puts("94"); 97 | puts("Buzz"); 98 | puts("Fizz"); 99 | puts("97"); 100 | puts("98"); 101 | puts("Fizz"); 102 | puts("Buzz"); 103 | } 104 | -------------------------------------------------------------------------------- /fizzbuzz123.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define PRINT_LINE (__LINE__ % 15 == 6 ? puts("FizzBuzz") : \ 3 | __LINE__ % 3 == 0 ? puts("Fizz") : \ 4 | __LINE__ % 5 == 1 ? puts("Buzz") : \ 5 | printf("%d\n", __LINE__ - 6)) 6 | int main(void) { 7 | PRINT_LINE; 8 | PRINT_LINE; 9 | PRINT_LINE; 10 | PRINT_LINE; 11 | PRINT_LINE; 12 | PRINT_LINE; 13 | PRINT_LINE; 14 | PRINT_LINE; 15 | PRINT_LINE; 16 | PRINT_LINE; 17 | PRINT_LINE; 18 | PRINT_LINE; 19 | PRINT_LINE; 20 | PRINT_LINE; 21 | PRINT_LINE; 22 | PRINT_LINE; 23 | PRINT_LINE; 24 | PRINT_LINE; 25 | PRINT_LINE; 26 | PRINT_LINE; 27 | PRINT_LINE; 28 | PRINT_LINE; 29 | PRINT_LINE; 30 | PRINT_LINE; 31 | PRINT_LINE; 32 | PRINT_LINE; 33 | PRINT_LINE; 34 | PRINT_LINE; 35 | PRINT_LINE; 36 | PRINT_LINE; 37 | PRINT_LINE; 38 | PRINT_LINE; 39 | PRINT_LINE; 40 | PRINT_LINE; 41 | PRINT_LINE; 42 | PRINT_LINE; 43 | PRINT_LINE; 44 | PRINT_LINE; 45 | PRINT_LINE; 46 | PRINT_LINE; 47 | PRINT_LINE; 48 | PRINT_LINE; 49 | PRINT_LINE; 50 | PRINT_LINE; 51 | PRINT_LINE; 52 | PRINT_LINE; 53 | PRINT_LINE; 54 | PRINT_LINE; 55 | PRINT_LINE; 56 | PRINT_LINE; 57 | PRINT_LINE; 58 | PRINT_LINE; 59 | PRINT_LINE; 60 | PRINT_LINE; 61 | PRINT_LINE; 62 | PRINT_LINE; 63 | PRINT_LINE; 64 | PRINT_LINE; 65 | PRINT_LINE; 66 | PRINT_LINE; 67 | PRINT_LINE; 68 | PRINT_LINE; 69 | PRINT_LINE; 70 | PRINT_LINE; 71 | PRINT_LINE; 72 | PRINT_LINE; 73 | PRINT_LINE; 74 | PRINT_LINE; 75 | PRINT_LINE; 76 | PRINT_LINE; 77 | PRINT_LINE; 78 | PRINT_LINE; 79 | PRINT_LINE; 80 | PRINT_LINE; 81 | PRINT_LINE; 82 | PRINT_LINE; 83 | PRINT_LINE; 84 | PRINT_LINE; 85 | PRINT_LINE; 86 | PRINT_LINE; 87 | PRINT_LINE; 88 | PRINT_LINE; 89 | PRINT_LINE; 90 | PRINT_LINE; 91 | PRINT_LINE; 92 | PRINT_LINE; 93 | PRINT_LINE; 94 | PRINT_LINE; 95 | PRINT_LINE; 96 | PRINT_LINE; 97 | PRINT_LINE; 98 | PRINT_LINE; 99 | PRINT_LINE; 100 | PRINT_LINE; 101 | PRINT_LINE; 102 | PRINT_LINE; 103 | PRINT_LINE; 104 | PRINT_LINE; 105 | PRINT_LINE; 106 | PRINT_LINE; 107 | } 108 | -------------------------------------------------------------------------------- /fizzbuzz124.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define LINE (__LINE__&0xff) 3 | #define PRINT_LINE (LINE % 15 == 0 ? puts("FizzBuzz") : \ 4 | LINE % 3 == 0 ? puts("Fizz") : \ 5 | LINE % 5 == 0 ? puts("Buzz") : \ 6 | printf("%d\n", LINE)) 7 | int main(void) { 8 | #line 257 9 | PRINT_LINE; 10 | PRINT_LINE; 11 | PRINT_LINE; 12 | PRINT_LINE; 13 | PRINT_LINE; 14 | PRINT_LINE; 15 | PRINT_LINE; 16 | PRINT_LINE; 17 | PRINT_LINE; 18 | PRINT_LINE; 19 | PRINT_LINE; 20 | PRINT_LINE; 21 | PRINT_LINE; 22 | PRINT_LINE; 23 | PRINT_LINE; 24 | PRINT_LINE; 25 | PRINT_LINE; 26 | PRINT_LINE; 27 | PRINT_LINE; 28 | PRINT_LINE; 29 | PRINT_LINE; 30 | PRINT_LINE; 31 | PRINT_LINE; 32 | PRINT_LINE; 33 | PRINT_LINE; 34 | PRINT_LINE; 35 | PRINT_LINE; 36 | PRINT_LINE; 37 | PRINT_LINE; 38 | PRINT_LINE; 39 | PRINT_LINE; 40 | PRINT_LINE; 41 | PRINT_LINE; 42 | PRINT_LINE; 43 | PRINT_LINE; 44 | PRINT_LINE; 45 | PRINT_LINE; 46 | PRINT_LINE; 47 | PRINT_LINE; 48 | PRINT_LINE; 49 | PRINT_LINE; 50 | PRINT_LINE; 51 | PRINT_LINE; 52 | PRINT_LINE; 53 | PRINT_LINE; 54 | PRINT_LINE; 55 | PRINT_LINE; 56 | PRINT_LINE; 57 | PRINT_LINE; 58 | PRINT_LINE; 59 | PRINT_LINE; 60 | PRINT_LINE; 61 | PRINT_LINE; 62 | PRINT_LINE; 63 | PRINT_LINE; 64 | PRINT_LINE; 65 | PRINT_LINE; 66 | PRINT_LINE; 67 | PRINT_LINE; 68 | PRINT_LINE; 69 | PRINT_LINE; 70 | PRINT_LINE; 71 | PRINT_LINE; 72 | PRINT_LINE; 73 | PRINT_LINE; 74 | PRINT_LINE; 75 | PRINT_LINE; 76 | PRINT_LINE; 77 | PRINT_LINE; 78 | PRINT_LINE; 79 | PRINT_LINE; 80 | PRINT_LINE; 81 | PRINT_LINE; 82 | PRINT_LINE; 83 | PRINT_LINE; 84 | PRINT_LINE; 85 | PRINT_LINE; 86 | PRINT_LINE; 87 | PRINT_LINE; 88 | PRINT_LINE; 89 | PRINT_LINE; 90 | PRINT_LINE; 91 | PRINT_LINE; 92 | PRINT_LINE; 93 | PRINT_LINE; 94 | PRINT_LINE; 95 | PRINT_LINE; 96 | PRINT_LINE; 97 | PRINT_LINE; 98 | PRINT_LINE; 99 | PRINT_LINE; 100 | PRINT_LINE; 101 | PRINT_LINE; 102 | PRINT_LINE; 103 | PRINT_LINE; 104 | PRINT_LINE; 105 | PRINT_LINE; 106 | PRINT_LINE; 107 | PRINT_LINE; 108 | PRINT_LINE; 109 | } 110 | -------------------------------------------------------------------------------- /list.txt: -------------------------------------------------------------------------------- 1 | fizzbuzz001.c 2 | fizzbuzz002.c 3 | fizzbuzz003.c 4 | fizzbuzz004.c 5 | fizzbuzz005.c 6 | fizzbuzz006.c 7 | fizzbuzz007.c 8 | fizzbuzz008.c 9 | fizzbuzz009.c 10 | fizzbuzz010.c 11 | fizzbuzz011.c 12 | fizzbuzz012.c 13 | fizzbuzz013.c 14 | fizzbuzz014.c 15 | fizzbuzz015.c 16 | fizzbuzz016.c 17 | fizzbuzz017.c 18 | fizzbuzz018.c 19 | fizzbuzz019.c 20 | fizzbuzz020.c 21 | fizzbuzz021.c 22 | fizzbuzz022.c 23 | fizzbuzz023.c 24 | fizzbuzz024.c 25 | fizzbuzz025.c 26 | fizzbuzz026.c 27 | fizzbuzz027.c 28 | fizzbuzz028.c 29 | fizzbuzz029.c 30 | fizzbuzz030.c 31 | fizzbuzz031.c 32 | fizzbuzz032.c 33 | fizzbuzz033.c 34 | fizzbuzz034.c 35 | fizzbuzz035.c 36 | fizzbuzz036.c 37 | fizzbuzz037.c 38 | fizzbuzz038.c 39 | fizzbuzz039.c 40 | fizzbuzz040.c 41 | fizzbuzz041.c 42 | fizzbuzz042.c 43 | fizzbuzz043.c 44 | fizzbuzz044.c 45 | fizzbuzz045.c 46 | fizzbuzz046.c 47 | fizzbuzz047.c 48 | fizzbuzz048.c 49 | fizzbuzz049.c 50 | fizzbuzz050.c 51 | fizzbuzz051.c 52 | fizzbuzz052.c 53 | fizzbuzz053.c 54 | fizzbuzz054.c 55 | fizzbuzz055.c 56 | fizzbuzz056.c 57 | fizzbuzz057.c 58 | fizzbuzz058.c 59 | fizzbuzz059.c 60 | fizzbuzz060.c 61 | fizzbuzz061.c 62 | fizzbuzz062.c 63 | fizzbuzz063.c 64 | fizzbuzz064.c 65 | fizzbuzz065.c 66 | fizzbuzz066.c 67 | fizzbuzz067.c 68 | fizzbuzz068.c 69 | fizzbuzz069.c 70 | fizzbuzz070.c 71 | fizzbuzz071.c 72 | fizzbuzz072.c 73 | fizzbuzz073.c 74 | fizzbuzz074.c 75 | fizzbuzz075.c 76 | fizzbuzz076.c 77 | fizzbuzz077.c 78 | fizzbuzz078.c 79 | fizzbuzz079.c 80 | fizzbuzz080.c 81 | fizzbuzz081.c 82 | fizzbuzz082.c 83 | fizzbuzz083.c 84 | fizzbuzz084.c 85 | fizzbuzz085.c 86 | fizzbuzz086.c 87 | fizzbuzz087.c 88 | fizzbuzz088.c 89 | fizzbuzz089.c 90 | fizzbuzz090.c 91 | fizzbuzz091.c 92 | fizzbuzz092.c 93 | fizzbuzz093.c 94 | fizzbuzz094.c 95 | fizzbuzz095.c 96 | fizzbuzz096.c 97 | fizzbuzz097.c 98 | fizzbuzz098.c 99 | fizzbuzz099.c 100 | fizzbuzz100.c 101 | fizzbuzz101.c 102 | fizzbuzz102.c 103 | fizzbuzz103.c 104 | fizzbuzz104.c 105 | fizzbuzz105.c 106 | fizzbuzz106.c 107 | fizzbuzz107.c 108 | fizzbuzz108.c 109 | fizzbuzz109.c 110 | fizzbuzz110.c 111 | fizzbuzz111.c 112 | fizzbuzz112.c 113 | fizzbuzz113.c 114 | fizzbuzz114.c 115 | fizzbuzz115.c 116 | fizzbuzz116.c 117 | fizzbuzz117.c 118 | fizzbuzz118.c 119 | fizzbuzz119.c 120 | fizzbuzz120.c 121 | fizzbuzz121.c 122 | fizzbuzz122.c 123 | fizzbuzz123.c 124 | fizzbuzz124.c 125 | fizzbuzz125.c 126 | fizzbuzz126.c 127 | fizzbuzz127.c 128 | fizzbuzz128.c 129 | fizzbuzz129.c 130 | fizzbuzz130.c 131 | fizzbuzz131.c 132 | fizzbuzz132.c 133 | fizzbuzz133.c 134 | fizzbuzz134.c 135 | fizzbuzz135.c 136 | fizzbuzz136.c 137 | fizzbuzz137.c 138 | fizzbuzz138.c 139 | fizzbuzz139.c 140 | fizzbuzz140.c 141 | fizzbuzz141.c 142 | fizzbuzz142.c 143 | fizzbuzz143.c 144 | fizzbuzz144.c 145 | fizzbuzz145.c 146 | fizzbuzz146.c 147 | -------------------------------------------------------------------------------- /fizzbuzz109.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static const char fb[] = { 4 | 0x31, 0x0a, 0x32, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x34, 0x0a, 5 | 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x37, 6 | 0x0a, 0x38, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x42, 0x75, 0x7a, 7 | 0x7a, 0x0a, 0x31, 0x31, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x31, 8 | 0x33, 0x0a, 0x31, 0x34, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x42, 0x75, 9 | 0x7a, 0x7a, 0x0a, 0x31, 0x36, 0x0a, 0x31, 0x37, 0x0a, 0x46, 0x69, 10 | 0x7a, 0x7a, 0x0a, 0x31, 0x39, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 11 | 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x32, 0x32, 0x0a, 0x32, 0x33, 0x0a, 12 | 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x32, 13 | 0x36, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x32, 0x38, 0x0a, 0x32, 14 | 0x39, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 15 | 0x33, 0x31, 0x0a, 0x33, 0x32, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 16 | 0x33, 0x34, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x46, 0x69, 0x7a, 17 | 0x7a, 0x0a, 0x33, 0x37, 0x0a, 0x33, 0x38, 0x0a, 0x46, 0x69, 0x7a, 18 | 0x7a, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x34, 0x31, 0x0a, 0x46, 19 | 0x69, 0x7a, 0x7a, 0x0a, 0x34, 0x33, 0x0a, 0x34, 0x34, 0x0a, 0x46, 20 | 0x69, 0x7a, 0x7a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x34, 0x36, 0x0a, 21 | 0x34, 0x37, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x34, 0x39, 0x0a, 22 | 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x35, 23 | 0x32, 0x0a, 0x35, 0x33, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x42, 24 | 0x75, 0x7a, 0x7a, 0x0a, 0x35, 0x36, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 25 | 0x0a, 0x35, 0x38, 0x0a, 0x35, 0x39, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 26 | 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x36, 0x31, 0x0a, 0x36, 0x32, 0x0a, 27 | 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x36, 0x34, 0x0a, 0x42, 0x75, 0x7a, 28 | 0x7a, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x36, 0x37, 0x0a, 0x36, 29 | 0x38, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 30 | 0x0a, 0x37, 0x31, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x37, 0x33, 31 | 0x0a, 0x37, 0x34, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x42, 0x75, 0x7a, 32 | 0x7a, 0x0a, 0x37, 0x36, 0x0a, 0x37, 0x37, 0x0a, 0x46, 0x69, 0x7a, 33 | 0x7a, 0x0a, 0x37, 0x39, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x46, 34 | 0x69, 0x7a, 0x7a, 0x0a, 0x38, 0x32, 0x0a, 0x38, 0x33, 0x0a, 0x46, 35 | 0x69, 0x7a, 0x7a, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x38, 0x36, 36 | 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x38, 0x38, 0x0a, 0x38, 0x39, 37 | 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x39, 38 | 0x31, 0x0a, 0x39, 0x32, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 0x0a, 0x39, 39 | 0x34, 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 40 | 0x0a, 0x39, 0x37, 0x0a, 0x39, 0x38, 0x0a, 0x46, 0x69, 0x7a, 0x7a, 41 | 0x0a, 0x42, 0x75, 0x7a, 0x7a, 0x0a, 42 | }; 43 | 44 | int main(void) { 45 | for (int i = 0; i < sizeof fb; i ++) { 46 | putchar(fb[i]); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /fizzbuzz067.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | for (const char *p = (const char[]){ 4 | '1', '\n', '2', '\n', 'F', 'i', 'z', 'z', '\n', '4', '\n', 5 | 'B', 'u', 'z', 'z', '\n', 'F', 'i', 'z', 'z', '\n', '7', 6 | '\n', '8', '\n', 'F', 'i', 'z', 'z', '\n', 'B', 'u', 'z', 7 | 'z', '\n', '1', '1', '\n', 'F', 'i', 'z', 'z', '\n', '1', 8 | '3', '\n', '1', '4', '\n', 'F', 'i', 'z', 'z', 'B', 'u', 9 | 'z', 'z', '\n', '1', '6', '\n', '1', '7', '\n', 'F', 'i', 10 | 'z', 'z', '\n', '1', '9', '\n', 'B', 'u', 'z', 'z', '\n', 11 | 'F', 'i', 'z', 'z', '\n', '2', '2', '\n', '2', '3', '\n', 12 | 'F', 'i', 'z', 'z', '\n', 'B', 'u', 'z', 'z', '\n', '2', 13 | '6', '\n', 'F', 'i', 'z', 'z', '\n', '2', '8', '\n', '2', 14 | '9', '\n', 'F', 'i', 'z', 'z', 'B', 'u', 'z', 'z', '\n', 15 | '3', '1', '\n', '3', '2', '\n', 'F', 'i', 'z', 'z', '\n', 16 | '3', '4', '\n', 'B', 'u', 'z', 'z', '\n', 'F', 'i', 'z', 17 | 'z', '\n', '3', '7', '\n', '3', '8', '\n', 'F', 'i', 'z', 18 | 'z', '\n', 'B', 'u', 'z', 'z', '\n', '4', '1', '\n', 'F', 19 | 'i', 'z', 'z', '\n', '4', '3', '\n', '4', '4', '\n', 'F', 20 | 'i', 'z', 'z', 'B', 'u', 'z', 'z', '\n', '4', '6', '\n', 21 | '4', '7', '\n', 'F', 'i', 'z', 'z', '\n', '4', '9', '\n', 22 | 'B', 'u', 'z', 'z', '\n', 'F', 'i', 'z', 'z', '\n', '5', 23 | '2', '\n', '5', '3', '\n', 'F', 'i', 'z', 'z', '\n', 'B', 24 | 'u', 'z', 'z', '\n', '5', '6', '\n', 'F', 'i', 'z', 'z', 25 | '\n', '5', '8', '\n', '5', '9', '\n', 'F', 'i', 'z', 'z', 26 | 'B', 'u', 'z', 'z', '\n', '6', '1', '\n', '6', '2', '\n', 27 | 'F', 'i', 'z', 'z', '\n', '6', '4', '\n', 'B', 'u', 'z', 28 | 'z', '\n', 'F', 'i', 'z', 'z', '\n', '6', '7', '\n', '6', 29 | '8', '\n', 'F', 'i', 'z', 'z', '\n', 'B', 'u', 'z', 'z', 30 | '\n', '7', '1', '\n', 'F', 'i', 'z', 'z', '\n', '7', '3', 31 | '\n', '7', '4', '\n', 'F', 'i', 'z', 'z', 'B', 'u', 'z', 32 | 'z', '\n', '7', '6', '\n', '7', '7', '\n', 'F', 'i', 'z', 33 | 'z', '\n', '7', '9', '\n', 'B', 'u', 'z', 'z', '\n', 'F', 34 | 'i', 'z', 'z', '\n', '8', '2', '\n', '8', '3', '\n', 'F', 35 | 'i', 'z', 'z', '\n', 'B', 'u', 'z', 'z', '\n', '8', '6', 36 | '\n', 'F', 'i', 'z', 'z', '\n', '8', '8', '\n', '8', '9', 37 | '\n', 'F', 'i', 'z', 'z', 'B', 'u', 'z', 'z', '\n', '9', 38 | '1', '\n', '9', '2', '\n', 'F', 'i', 'z', 'z', '\n', '9', 39 | '4', '\n', 'B', 'u', 'z', 'z', '\n', 'F', 'i', 'z', 'z', 40 | '\n', '9', '7', '\n', '9', '8', '\n', 'F', 'i', 'z', 'z', 41 | '\n', 'B', 'u', 'z', 'z', '\n', '\0' 42 | }; 43 | *p != '\0'; 44 | p ++) 45 | { 46 | putchar(*p); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /fizzbuzz134.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef __COUNTER__ 4 | #error "__COUNTER__ is not defined" 5 | #endif 6 | 7 | #define LINE(i) \ 8 | i % 15 == 0 ? puts("FizzBuzz") : \ 9 | i % 3 == 0 ? puts("Fizz") : \ 10 | i % 5 == 0 ? puts("Buzz") : \ 11 | printf("%d\n", i) 12 | 13 | int main(void) { 14 | __COUNTER__; 15 | LINE(__COUNTER__); 16 | LINE(__COUNTER__); 17 | LINE(__COUNTER__); 18 | LINE(__COUNTER__); 19 | LINE(__COUNTER__); 20 | LINE(__COUNTER__); 21 | LINE(__COUNTER__); 22 | LINE(__COUNTER__); 23 | LINE(__COUNTER__); 24 | LINE(__COUNTER__); 25 | LINE(__COUNTER__); 26 | LINE(__COUNTER__); 27 | LINE(__COUNTER__); 28 | LINE(__COUNTER__); 29 | LINE(__COUNTER__); 30 | LINE(__COUNTER__); 31 | LINE(__COUNTER__); 32 | LINE(__COUNTER__); 33 | LINE(__COUNTER__); 34 | LINE(__COUNTER__); 35 | LINE(__COUNTER__); 36 | LINE(__COUNTER__); 37 | LINE(__COUNTER__); 38 | LINE(__COUNTER__); 39 | LINE(__COUNTER__); 40 | LINE(__COUNTER__); 41 | LINE(__COUNTER__); 42 | LINE(__COUNTER__); 43 | LINE(__COUNTER__); 44 | LINE(__COUNTER__); 45 | LINE(__COUNTER__); 46 | LINE(__COUNTER__); 47 | LINE(__COUNTER__); 48 | LINE(__COUNTER__); 49 | LINE(__COUNTER__); 50 | LINE(__COUNTER__); 51 | LINE(__COUNTER__); 52 | LINE(__COUNTER__); 53 | LINE(__COUNTER__); 54 | LINE(__COUNTER__); 55 | LINE(__COUNTER__); 56 | LINE(__COUNTER__); 57 | LINE(__COUNTER__); 58 | LINE(__COUNTER__); 59 | LINE(__COUNTER__); 60 | LINE(__COUNTER__); 61 | LINE(__COUNTER__); 62 | LINE(__COUNTER__); 63 | LINE(__COUNTER__); 64 | LINE(__COUNTER__); 65 | LINE(__COUNTER__); 66 | LINE(__COUNTER__); 67 | LINE(__COUNTER__); 68 | LINE(__COUNTER__); 69 | LINE(__COUNTER__); 70 | LINE(__COUNTER__); 71 | LINE(__COUNTER__); 72 | LINE(__COUNTER__); 73 | LINE(__COUNTER__); 74 | LINE(__COUNTER__); 75 | LINE(__COUNTER__); 76 | LINE(__COUNTER__); 77 | LINE(__COUNTER__); 78 | LINE(__COUNTER__); 79 | LINE(__COUNTER__); 80 | LINE(__COUNTER__); 81 | LINE(__COUNTER__); 82 | LINE(__COUNTER__); 83 | LINE(__COUNTER__); 84 | LINE(__COUNTER__); 85 | LINE(__COUNTER__); 86 | LINE(__COUNTER__); 87 | LINE(__COUNTER__); 88 | LINE(__COUNTER__); 89 | LINE(__COUNTER__); 90 | LINE(__COUNTER__); 91 | LINE(__COUNTER__); 92 | LINE(__COUNTER__); 93 | LINE(__COUNTER__); 94 | LINE(__COUNTER__); 95 | LINE(__COUNTER__); 96 | LINE(__COUNTER__); 97 | LINE(__COUNTER__); 98 | LINE(__COUNTER__); 99 | LINE(__COUNTER__); 100 | LINE(__COUNTER__); 101 | LINE(__COUNTER__); 102 | LINE(__COUNTER__); 103 | LINE(__COUNTER__); 104 | LINE(__COUNTER__); 105 | LINE(__COUNTER__); 106 | LINE(__COUNTER__); 107 | LINE(__COUNTER__); 108 | LINE(__COUNTER__); 109 | LINE(__COUNTER__); 110 | LINE(__COUNTER__); 111 | LINE(__COUNTER__); 112 | LINE(__COUNTER__); 113 | LINE(__COUNTER__); 114 | LINE(__COUNTER__); 115 | } 116 | -------------------------------------------------------------------------------- /fizzbuzz061.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void sort(char *s, short *index, int count) { 4 | for (int i = 0; i < count-18; i ++) { 5 | for (int j = 0; j < count-1; j ++) { 6 | if (index[j] > index[j+1]) { 7 | const short tmpi = index[j]; 8 | const char tmpc = s[j]; 9 | index[j] = index[j+1]; 10 | s[j] = s[j+1]; 11 | index[j+1] = tmpi; 12 | s[j+1] = tmpc; 13 | } 14 | } 15 | } 16 | } 17 | 18 | int main(void) { 19 | const struct { char c; short n; } seq[] = { 20 | '\n', 100, '1', 13, '2', 12, '3', 11, '4', 13, '5', 5, '6', 21 | 11, '7', 13, '8', 12, '9', 11, 'B', 20, 'F', 33, 'i', 33, 22 | 'u', 20, 'z', 106, 23 | }; 24 | short index[] = { 25 | 49, 20, 181, 42, 279, 205, 103, 192, 141, 145, 195, 163, 215, 26 | 297, 188, 270, 160, 276, 320, 233, 14, 178, 323, 167, 113, 27 | 272, 127, 341, 52, 18, 10, 202, 72, 93, 130, 239, 124, 30, 28 | 293, 344, 212, 116, 287, 308, 225, 106, 109, 247, 59, 236, 29 | 310, 218, 337, 150, 32, 39, 26, 22, 157, 96, 250, 36, 62, 351, 30 | 326, 267, 174, 8, 304, 355, 283, 257, 2, 260, 134, 83, 184, 31 | 86, 120, 170, 330, 313, 290, 66, 301, 229, 138, 222, 347, 70, 32 | 55, 148, 254, 90, 199, 333, 4, 79, 243, 75, 60, 1, 214, 31, 33 | 249, 105, 50, 37, 53, 140, 322, 31, 40, 71, 3, 180, 94, 289, 34 | 91, 71, 84, 217, 108, 73, 325, 107, 114, 183, 292, 128, 125, 35 | 38, 147, 256, 74, 104, 149, 224, 161, 259, 168, 139, 158, 9, 36 | 115, 149, 146, 41, 332, 203, 200, 182, 193, 179, 234, 159, 37 | 223, 85, 237, 269, 303, 213, 51, 216, 194, 343, 54, 248, 277, 38 | 255, 271, 162, 126, 268, 235, 271, 19, 258, 21, 309, 201, 291, 39 | 302, 311, 346, 92, 129, 309, 288, 238, 169, 331, 324, 312, 40 | 61, 345, 95, 321, 278, 342, 204, 226, 334, 100, 11, 280, 80, 41 | 117, 189, 27, 298, 352, 264, 317, 154, 46, 135, 63, 171, 209, 42 | 244, 97, 142, 284, 327, 185, 338, 206, 121, 43, 110, 219, 15, 43 | 33, 294, 23, 76, 305, 151, 164, 240, 131, 87, 314, 56, 175, 44 | 348, 67, 273, 5, 251, 196, 230, 261, 328, 68, 24, 220, 315, 45 | 6, 295, 306, 274, 197, 231, 44, 16, 57, 88, 241, 339, 207, 46 | 77, 111, 262, 349, 186, 252, 143, 285, 165, 34, 152, 122, 47 | 132, 98, 176, 64, 265, 281, 245, 190, 210, 12, 155, 101, 318, 48 | 172, 299, 28, 353, 136, 81, 118, 47, 227, 335, 82, 187, 99, 49 | 266, 300, 48, 329, 208, 266, 25, 316, 211, 123, 58, 29, 65, 50 | 246, 58, 340, 13, 173, 307, 156, 13, 102, 35, 282, 319, 275, 51 | 242, 286, 17, 242, 78, 253, 354, 187, 228, 78, 296, 153, 228, 52 | 336, 48, 144, 17, 99, 173, 123, 45, 319, 69, 191, 112, 286, 53 | 153, 82, 133, 177, 296, 69, 133, 263, 300, 119, 221, 166, 54 | 45, 340, 166, 211, 137, 253, 336, 307, 177, 350, 25, 102, 65, 55 | 221, 156, 198, 137, 198, 329, 282, 89, 354, 29, 7, 232, 191, 56 | 144, 35, 7, 350, 246, 112, 119, 89, 208, 275, 232, 263, 316, 57 | }; 58 | char output[413]; 59 | int i = 0; 60 | for (int j = 0; j < sizeof seq / sizeof *seq; j ++) { 61 | for (int k = 0; k < seq[j].n; k ++) { 62 | output[i++] = seq[j].c; 63 | } 64 | } 65 | sort(output, index, sizeof output); 66 | fwrite(output, 1, sizeof output, stdout); 67 | } 68 | -------------------------------------------------------------------------------- /verify: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | strict=false 4 | tests="" 5 | clang=false 6 | icx=false 7 | musl=false 8 | tcc=false 9 | standard=-std=c11 10 | 11 | for arg in "$@" ; do 12 | if [ "$arg" = "-strict" ] ; then 13 | strict=true 14 | elif [ "$arg" = "-clang" ] ; then 15 | clang=true 16 | elif [ "$arg" = "-icx" ] ; then 17 | icx=true 18 | elif [ "$arg" = "-musl" ] ; then 19 | musl=true 20 | elif [ "$arg" = "-tcc" ] ; then 21 | tcc=true 22 | elif [ "$arg" = "-c90" ] ; then 23 | standard=-std=c90 24 | elif [ "$arg" = "-c99" ] ; then 25 | standard=-std=c99 26 | elif [ "$arg" = "-c11" ] ; then 27 | standard=-std=c11 28 | elif [ "$arg" = "-c17" ] ; then 29 | standard=-std=c17 30 | elif [ -f "$arg" ] ; then 31 | tests="$tests $arg" 32 | else 33 | echo "Usage: $0 [-strict] [-clang] [-icx] [-c90|-c99|-c11|-c17]" 1>&2 34 | exit 1 35 | fi 36 | done 37 | 38 | if $clang ; then 39 | CC=clang 40 | elif $icx ; then 41 | CC=icx 42 | elif $musl ; then 43 | CC=musl-gcc 44 | elif $tcc ; then 45 | CC=tcc 46 | else 47 | CC=gcc 48 | fi 49 | 50 | if ! $tcc ; then 51 | if $strict ; then 52 | CFLAGS="$standard -pedantic-errors -Wall -Wextra -O3" 53 | else 54 | CFLAGS="$standard -Wno-format-extra-args" 55 | fi 56 | fi 57 | 58 | # if $clang && ! $strict ; then 59 | # CFLAGS="$CFLAGS -Wno-logical-op-parentheses" 60 | # fi 61 | 62 | if [ ! "$tests" ] ; then 63 | tests=$(cat list.txt) 64 | fi 65 | 66 | ok=true 67 | failures='' 68 | count=0 69 | for file in $tests ; do 70 | echo -n . 71 | count=$(expr $count + 1) 72 | if [ $(expr $count % 50) -eq 0 ] ; then 73 | echo '' 74 | fi 75 | exe=$(basename $file .c) 76 | out=$(basename $file .c).out 77 | if [ "$file" = "fizzbuzz007.c" ] ; then 78 | $CC $CFLAGS -Wno-logical-op-parentheses $file -o $exe 79 | elif [ "$file" = "fizzbuzz026.c" ] ; then 80 | $CC $CFLAGS -Wno-logical-op-parentheses $file -o $exe 81 | elif [ "$file" = "fizzbuzz027.c" ] || [ "$file" = "fizzbuzz068.c" ] ; then 82 | if [ "$CC" = "tcc" ] ; then 83 | $CC $CFLAGS -lpthread $file -o $exe 84 | else 85 | $CC $CFLAGS -pthread $file -o $exe 86 | fi 87 | elif [ "$file" = "fizzbuzz064.c" ] ; then 88 | $CC $CFLAGS -Wno-multichar $file -o $exe 89 | elif [ "$file" = "fizzbuzz076.c" ] ; then 90 | $CC $CFLAGS $file -o $exe -lgmp 91 | elif [ "$file" = "fizzbuzz106.c" ] ; then 92 | $CC $CFLAGS $file -o $exe < fizzbuzz001.c 93 | elif [ "$file" = "fizzbuzz107.c" ] ; then 94 | # icx (Intel's compiler) treats \ characters on its command 95 | # line differently than other compilers. 96 | if [ "$CC" = "icx" ] ; then 97 | newline='\\n' 98 | else 99 | newline='\n' 100 | fi 101 | $CC $CFLAGS \ 102 | -DLINE02='int main(void) {' \ 103 | -DLINE03=' for (int i = 1; i <= 100; i ++) {' \ 104 | -DLINE04=' if (i % 15 == 0) {' \ 105 | -DLINE05=' puts("FizzBuzz");' \ 106 | -DLINE06=' }' \ 107 | -DLINE07=' else if (i % 3 == 0) {' \ 108 | -DLINE08=' puts("Fizz");' \ 109 | -DLINE09=' }' \ 110 | -DLINE10=' else if (i % 5 == 0) {' \ 111 | -DLINE11=' puts("Buzz");' \ 112 | -DLINE12=' }' \ 113 | -DLINE13=' else {' \ 114 | -DLINE14=' printf("%d'"$newline"'", i);' \ 115 | -DLINE15=' }' \ 116 | -DLINE16=' }' \ 117 | -DLINE17='}' \ 118 | $file -o $exe 119 | elif [ "$file" = "fizzbuzz119.c" ] ; then 120 | $CC $CFLAGS $file -o $exe -lm 121 | else 122 | $CC $CFLAGS $file -o $exe 123 | fi 124 | ./$exe >$out 125 | if ! cmp -s $out expected-output.txt ; then 126 | ok=false 127 | failures="$failures $file" 128 | fi 129 | rm -f $exe $out 130 | done 131 | if [ $(expr $count % 50) -ne 0 ] ; then 132 | echo '' 133 | fi 134 | 135 | if $ok ; then 136 | echo OK 137 | else 138 | echo Failures: $failures 139 | exit 1 140 | fi 141 | 142 | -------------------------------------------------------------------------------- /fizzbuzz125.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | #line 1 "1" 4 | puts(__FILE__); 5 | #line 1 "2" 6 | puts(__FILE__); 7 | #line 1 "Fizz" 8 | puts(__FILE__); 9 | #line 1 "4" 10 | puts(__FILE__); 11 | #line 1 "Buzz" 12 | puts(__FILE__); 13 | #line 1 "Fizz" 14 | puts(__FILE__); 15 | #line 1 "7" 16 | puts(__FILE__); 17 | #line 1 "8" 18 | puts(__FILE__); 19 | #line 1 "Fizz" 20 | puts(__FILE__); 21 | #line 1 "Buzz" 22 | puts(__FILE__); 23 | #line 1 "11" 24 | puts(__FILE__); 25 | #line 1 "Fizz" 26 | puts(__FILE__); 27 | #line 1 "13" 28 | puts(__FILE__); 29 | #line 1 "14" 30 | puts(__FILE__); 31 | #line 1 "FizzBuzz" 32 | puts(__FILE__); 33 | #line 1 "16" 34 | puts(__FILE__); 35 | #line 1 "17" 36 | puts(__FILE__); 37 | #line 1 "Fizz" 38 | puts(__FILE__); 39 | #line 1 "19" 40 | puts(__FILE__); 41 | #line 1 "Buzz" 42 | puts(__FILE__); 43 | #line 1 "Fizz" 44 | puts(__FILE__); 45 | #line 1 "22" 46 | puts(__FILE__); 47 | #line 1 "23" 48 | puts(__FILE__); 49 | #line 1 "Fizz" 50 | puts(__FILE__); 51 | #line 1 "Buzz" 52 | puts(__FILE__); 53 | #line 1 "26" 54 | puts(__FILE__); 55 | #line 1 "Fizz" 56 | puts(__FILE__); 57 | #line 1 "28" 58 | puts(__FILE__); 59 | #line 1 "29" 60 | puts(__FILE__); 61 | #line 1 "FizzBuzz" 62 | puts(__FILE__); 63 | #line 1 "31" 64 | puts(__FILE__); 65 | #line 1 "32" 66 | puts(__FILE__); 67 | #line 1 "Fizz" 68 | puts(__FILE__); 69 | #line 1 "34" 70 | puts(__FILE__); 71 | #line 1 "Buzz" 72 | puts(__FILE__); 73 | #line 1 "Fizz" 74 | puts(__FILE__); 75 | #line 1 "37" 76 | puts(__FILE__); 77 | #line 1 "38" 78 | puts(__FILE__); 79 | #line 1 "Fizz" 80 | puts(__FILE__); 81 | #line 1 "Buzz" 82 | puts(__FILE__); 83 | #line 1 "41" 84 | puts(__FILE__); 85 | #line 1 "Fizz" 86 | puts(__FILE__); 87 | #line 1 "43" 88 | puts(__FILE__); 89 | #line 1 "44" 90 | puts(__FILE__); 91 | #line 1 "FizzBuzz" 92 | puts(__FILE__); 93 | #line 1 "46" 94 | puts(__FILE__); 95 | #line 1 "47" 96 | puts(__FILE__); 97 | #line 1 "Fizz" 98 | puts(__FILE__); 99 | #line 1 "49" 100 | puts(__FILE__); 101 | #line 1 "Buzz" 102 | puts(__FILE__); 103 | #line 1 "Fizz" 104 | puts(__FILE__); 105 | #line 1 "52" 106 | puts(__FILE__); 107 | #line 1 "53" 108 | puts(__FILE__); 109 | #line 1 "Fizz" 110 | puts(__FILE__); 111 | #line 1 "Buzz" 112 | puts(__FILE__); 113 | #line 1 "56" 114 | puts(__FILE__); 115 | #line 1 "Fizz" 116 | puts(__FILE__); 117 | #line 1 "58" 118 | puts(__FILE__); 119 | #line 1 "59" 120 | puts(__FILE__); 121 | #line 1 "FizzBuzz" 122 | puts(__FILE__); 123 | #line 1 "61" 124 | puts(__FILE__); 125 | #line 1 "62" 126 | puts(__FILE__); 127 | #line 1 "Fizz" 128 | puts(__FILE__); 129 | #line 1 "64" 130 | puts(__FILE__); 131 | #line 1 "Buzz" 132 | puts(__FILE__); 133 | #line 1 "Fizz" 134 | puts(__FILE__); 135 | #line 1 "67" 136 | puts(__FILE__); 137 | #line 1 "68" 138 | puts(__FILE__); 139 | #line 1 "Fizz" 140 | puts(__FILE__); 141 | #line 1 "Buzz" 142 | puts(__FILE__); 143 | #line 1 "71" 144 | puts(__FILE__); 145 | #line 1 "Fizz" 146 | puts(__FILE__); 147 | #line 1 "73" 148 | puts(__FILE__); 149 | #line 1 "74" 150 | puts(__FILE__); 151 | #line 1 "FizzBuzz" 152 | puts(__FILE__); 153 | #line 1 "76" 154 | puts(__FILE__); 155 | #line 1 "77" 156 | puts(__FILE__); 157 | #line 1 "Fizz" 158 | puts(__FILE__); 159 | #line 1 "79" 160 | puts(__FILE__); 161 | #line 1 "Buzz" 162 | puts(__FILE__); 163 | #line 1 "Fizz" 164 | puts(__FILE__); 165 | #line 1 "82" 166 | puts(__FILE__); 167 | #line 1 "83" 168 | puts(__FILE__); 169 | #line 1 "Fizz" 170 | puts(__FILE__); 171 | #line 1 "Buzz" 172 | puts(__FILE__); 173 | #line 1 "86" 174 | puts(__FILE__); 175 | #line 1 "Fizz" 176 | puts(__FILE__); 177 | #line 1 "88" 178 | puts(__FILE__); 179 | #line 1 "89" 180 | puts(__FILE__); 181 | #line 1 "FizzBuzz" 182 | puts(__FILE__); 183 | #line 1 "91" 184 | puts(__FILE__); 185 | #line 1 "92" 186 | puts(__FILE__); 187 | #line 1 "Fizz" 188 | puts(__FILE__); 189 | #line 1 "94" 190 | puts(__FILE__); 191 | #line 1 "Buzz" 192 | puts(__FILE__); 193 | #line 1 "Fizz" 194 | puts(__FILE__); 195 | #line 1 "97" 196 | puts(__FILE__); 197 | #line 1 "98" 198 | puts(__FILE__); 199 | #line 1 "Fizz" 200 | puts(__FILE__); 201 | #line 1 "Buzz" 202 | puts(__FILE__); 203 | } 204 | -------------------------------------------------------------------------------- /fizzbuzz095.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void Fizz(void) { puts("Fizz"); } 4 | static void Buzz(void) { puts("Buzz"); } 5 | static void FizzBuzz(void) { puts("FizzBuzz"); } 6 | static void n1(void) { puts("1"); } 7 | static void n2(void) { puts("2"); } 8 | static void n4(void) { puts("4"); } 9 | static void n7(void) { puts("7"); } 10 | static void n8(void) { puts("8"); } 11 | static void n11(void) { puts("11"); } 12 | static void n13(void) { puts("13"); } 13 | static void n14(void) { puts("14"); } 14 | static void n16(void) { puts("16"); } 15 | static void n17(void) { puts("17"); } 16 | static void n19(void) { puts("19"); } 17 | static void n22(void) { puts("22"); } 18 | static void n23(void) { puts("23"); } 19 | static void n26(void) { puts("26"); } 20 | static void n28(void) { puts("28"); } 21 | static void n29(void) { puts("29"); } 22 | static void n31(void) { puts("31"); } 23 | static void n32(void) { puts("32"); } 24 | static void n34(void) { puts("34"); } 25 | static void n37(void) { puts("37"); } 26 | static void n38(void) { puts("38"); } 27 | static void n41(void) { puts("41"); } 28 | static void n43(void) { puts("43"); } 29 | static void n44(void) { puts("44"); } 30 | static void n46(void) { puts("46"); } 31 | static void n47(void) { puts("47"); } 32 | static void n49(void) { puts("49"); } 33 | static void n52(void) { puts("52"); } 34 | static void n53(void) { puts("53"); } 35 | static void n56(void) { puts("56"); } 36 | static void n58(void) { puts("58"); } 37 | static void n59(void) { puts("59"); } 38 | static void n61(void) { puts("61"); } 39 | static void n62(void) { puts("62"); } 40 | static void n64(void) { puts("64"); } 41 | static void n67(void) { puts("67"); } 42 | static void n68(void) { puts("68"); } 43 | static void n71(void) { puts("71"); } 44 | static void n73(void) { puts("73"); } 45 | static void n74(void) { puts("74"); } 46 | static void n76(void) { puts("76"); } 47 | static void n77(void) { puts("77"); } 48 | static void n79(void) { puts("79"); } 49 | static void n82(void) { puts("82"); } 50 | static void n83(void) { puts("83"); } 51 | static void n86(void) { puts("86"); } 52 | static void n88(void) { puts("88"); } 53 | static void n89(void) { puts("89"); } 54 | static void n91(void) { puts("91"); } 55 | static void n92(void) { puts("92"); } 56 | static void n94(void) { puts("94"); } 57 | static void n97(void) { puts("97"); } 58 | static void n98(void) { puts("98"); } 59 | 60 | static void print(void (*p)(void)) { 61 | p(); 62 | } 63 | 64 | int main(void) { 65 | print(n1); 66 | print(n2); 67 | print(Fizz); 68 | print(n4); 69 | print(Buzz); 70 | print(Fizz); 71 | print(n7); 72 | print(n8); 73 | print(Fizz); 74 | print(Buzz); 75 | print(n11); 76 | print(Fizz); 77 | print(n13); 78 | print(n14); 79 | print(FizzBuzz); 80 | print(n16); 81 | print(n17); 82 | print(Fizz); 83 | print(n19); 84 | print(Buzz); 85 | print(Fizz); 86 | print(n22); 87 | print(n23); 88 | print(Fizz); 89 | print(Buzz); 90 | print(n26); 91 | print(Fizz); 92 | print(n28); 93 | print(n29); 94 | print(FizzBuzz); 95 | print(n31); 96 | print(n32); 97 | print(Fizz); 98 | print(n34); 99 | print(Buzz); 100 | print(Fizz); 101 | print(n37); 102 | print(n38); 103 | print(Fizz); 104 | print(Buzz); 105 | print(n41); 106 | print(Fizz); 107 | print(n43); 108 | print(n44); 109 | print(FizzBuzz); 110 | print(n46); 111 | print(n47); 112 | print(Fizz); 113 | print(n49); 114 | print(Buzz); 115 | print(Fizz); 116 | print(n52); 117 | print(n53); 118 | print(Fizz); 119 | print(Buzz); 120 | print(n56); 121 | print(Fizz); 122 | print(n58); 123 | print(n59); 124 | print(FizzBuzz); 125 | print(n61); 126 | print(n62); 127 | print(Fizz); 128 | print(n64); 129 | print(Buzz); 130 | print(Fizz); 131 | print(n67); 132 | print(n68); 133 | print(Fizz); 134 | print(Buzz); 135 | print(n71); 136 | print(Fizz); 137 | print(n73); 138 | print(n74); 139 | print(FizzBuzz); 140 | print(n76); 141 | print(n77); 142 | print(Fizz); 143 | print(n79); 144 | print(Buzz); 145 | print(Fizz); 146 | print(n82); 147 | print(n83); 148 | print(Fizz); 149 | print(Buzz); 150 | print(n86); 151 | print(Fizz); 152 | print(n88); 153 | print(n89); 154 | print(FizzBuzz); 155 | print(n91); 156 | print(n92); 157 | print(Fizz); 158 | print(n94); 159 | print(Buzz); 160 | print(Fizz); 161 | print(n97); 162 | print(n98); 163 | print(Fizz); 164 | print(Buzz); 165 | } 166 | -------------------------------------------------------------------------------- /portability.md: -------------------------------------------------------------------------------- 1 | Most of these programs are (intended to be) 100% portable C, conforming 2 | to the ISO C99 and C11 standards. 3 | 4 | A few of them are non-portable, depending on implementation-defined 5 | features, or even on undefined behavior. 6 | 7 | Many of them rely on C99's ability to define a variable in a `for` loop. 8 | 9 | The `verify` script is a Bourne shell script, so it will only work 10 | on systems that provide the Bourne shell. It uses a number of 11 | UNIX-specific commands, and it assumes that the program's output 12 | can be compared for binary equivalence (using the `cmp` command) 13 | to the expected output. A system such as Windows with a different 14 | text file representation would break that assumption. 15 | 16 | Here I document the non-portable programs. Any programs not 17 | appearing on this list are intended to be portable. There may be 18 | some non-portabilities that I've missed. 19 | 20 | * `fizzbuzz003.c` 21 | This works only if standard input is seekable. The `verify` 22 | script ensures that it's run that way. If you compile and run it 23 | manually, it will fail with `exit(EXIT_FAILURE)`, probably with an 24 | error message like `ftell: Illegal seek`. 25 | 26 | * `fizzbuzz025.c` 27 | This relies on `printf` to support the `"%n"` conversion specifier. 28 | This is not an optional feature; any conforming hosted 29 | C implementation must support it. But there is at least one C 30 | runtime library implementation (the one used on Android) that doesn't 31 | support it because the maintainers consider it to be too dangerous. 32 | 33 | * `fizzbuzz027.c` 34 | This relies on the POSIX threads as specified in the `` 35 | header. This is obviously not portable to non-POSIX systems. 36 | It relies on the `verify` script to invoke the compiler properly. 37 | See also `fizzbuzz133.c`, which uses ISO C ``. 38 | 39 | * `fizzbuzz063.c` 40 | This assumes that identical string literals are stored in the 41 | same memory location. For example, the string literal `"drei"` 42 | occurs twice in the source code. If the compiler doesn't store them 43 | both in the same location, the test will fail. It is unspecified 44 | whether identical string literals are stored in the same location; 45 | the behavior can vary across different compilers, and is not required 46 | to be documented. 47 | 48 | * `fizzbuzz064.c` 49 | A multi-character constant such as `'10'` is of type `int` and 50 | has an implementation-defined value. This program assumes that 51 | distinct multi-character constants such as `'10'` and `'11'` have 52 | distinct values. This is not guaranteed by the language. 53 | 54 | * `fizzbuzz068.c` 55 | Like `fizzbuzz027.c`, this relies on POSIX threads, and on the `verify` 56 | script to invoke the compiler properly. 57 | 58 | * `fizzbuzz069.c` 59 | This relies on the existence of a file called `expected-output.txt`. 60 | 61 | * `fizzbuzz076.c` 62 | This relies on the non-standard GnuMP library and the `` header, 63 | and on the `verify` script to link it properly. 64 | 65 | * `fizzbuzz078.c` 66 | This relies on the existence of the type `uint16_t`, declared in 67 | ``. The header is required to exist in any conforming 68 | C99 or later implementation, but the type `uint16_t` will not be 69 | defined unless there is an integer type that meets its requirements, 70 | and a conforming implementation is not required to have such a type. 71 | 72 | * `fizzbuzz081.c` 73 | This is horribly non-portable. It searches memory near the entry 74 | point for the `main()` function for contents of a string literal. 75 | Futhermore, it converts the value of `main` (a function pointer) 76 | to `char*`, which has undefined behavior (gcc incorrectly says that 77 | it's forbidden by ISO C). 78 | 79 | * `fizzbuzz105.c` 80 | This sets up a 2-dimensional array of characters and *randomly* 81 | fills it in with correct values. If `rand()` misbehaves, it's 82 | possible that the entire array will never be filled in correctly 83 | and the program might never terminate. The standard places few 84 | requirements on the behavior of `rand()`. 85 | 86 | * `fizzbuzz106.c` 87 | Inspired by an early IOCCC winner, this is just 88 | `#include ` 89 | It relies on the existence of `/dev/stdin`, and on the `verify` 90 | script to feed it the correct input. 91 | 92 | * `fizzbuzz107.c` 93 | This relies on the `verify` script to invoke the compiler so that 94 | the macros are predefined, and on the compiler to accept command-line 95 | arguments to predefine macros. 96 | 97 | * `fizzbuzz114.c` 98 | This requires an ASCII-compatible character set. In practice, 99 | it's likely to work with anything other than EBCDIC. 100 | 101 | * `fizzbuzz133.c` 102 | This requires a C11 or higher implementation that supports 103 | ``, an optional feature. It also depends on some timing 104 | assumptions (the 30-millisecond sleep might need to be tweaked). 105 | 106 | * `fizzbuzz134.c` 107 | This requires a preprocessor that supports the `__COUNTER__` 108 | predefined macro, a GNU C extension. 109 | 110 | * `fizzbuzz141.c` 111 | Like `fizzbuzz105.c`, this can fail if `rand()` misbehaves. 112 | -------------------------------------------------------------------------------- /fizzbuzz064.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void inc(int *i) { 4 | switch (*i) { 5 | case '1': *i = '2'; break; 6 | case '2': *i = '3'; break; 7 | case '3': *i = '4'; break; 8 | case '4': *i = '5'; break; 9 | case '5': *i = '6'; break; 10 | case '6': *i = '7'; break; 11 | case '7': *i = '8'; break; 12 | case '8': *i = '9'; break; 13 | case '9': *i = '10'; break; 14 | case '10': *i = '11'; break; 15 | case '11': *i = '12'; break; 16 | case '12': *i = '13'; break; 17 | case '13': *i = '14'; break; 18 | case '14': *i = '15'; break; 19 | case '15': *i = '16'; break; 20 | case '16': *i = '17'; break; 21 | case '17': *i = '18'; break; 22 | case '18': *i = '19'; break; 23 | case '19': *i = '20'; break; 24 | case '20': *i = '21'; break; 25 | case '21': *i = '22'; break; 26 | case '22': *i = '23'; break; 27 | case '23': *i = '24'; break; 28 | case '24': *i = '25'; break; 29 | case '25': *i = '26'; break; 30 | case '26': *i = '27'; break; 31 | case '27': *i = '28'; break; 32 | case '28': *i = '29'; break; 33 | case '29': *i = '30'; break; 34 | case '30': *i = '31'; break; 35 | case '31': *i = '32'; break; 36 | case '32': *i = '33'; break; 37 | case '33': *i = '34'; break; 38 | case '34': *i = '35'; break; 39 | case '35': *i = '36'; break; 40 | case '36': *i = '37'; break; 41 | case '37': *i = '38'; break; 42 | case '38': *i = '39'; break; 43 | case '39': *i = '40'; break; 44 | case '40': *i = '41'; break; 45 | case '41': *i = '42'; break; 46 | case '42': *i = '43'; break; 47 | case '43': *i = '44'; break; 48 | case '44': *i = '45'; break; 49 | case '45': *i = '46'; break; 50 | case '46': *i = '47'; break; 51 | case '47': *i = '48'; break; 52 | case '48': *i = '49'; break; 53 | case '49': *i = '50'; break; 54 | case '50': *i = '51'; break; 55 | case '51': *i = '52'; break; 56 | case '52': *i = '53'; break; 57 | case '53': *i = '54'; break; 58 | case '54': *i = '55'; break; 59 | case '55': *i = '56'; break; 60 | case '56': *i = '57'; break; 61 | case '57': *i = '58'; break; 62 | case '58': *i = '59'; break; 63 | case '59': *i = '60'; break; 64 | case '60': *i = '61'; break; 65 | case '61': *i = '62'; break; 66 | case '62': *i = '63'; break; 67 | case '63': *i = '64'; break; 68 | case '64': *i = '65'; break; 69 | case '65': *i = '66'; break; 70 | case '66': *i = '67'; break; 71 | case '67': *i = '68'; break; 72 | case '68': *i = '69'; break; 73 | case '69': *i = '70'; break; 74 | case '70': *i = '71'; break; 75 | case '71': *i = '72'; break; 76 | case '72': *i = '73'; break; 77 | case '73': *i = '74'; break; 78 | case '74': *i = '75'; break; 79 | case '75': *i = '76'; break; 80 | case '76': *i = '77'; break; 81 | case '77': *i = '78'; break; 82 | case '78': *i = '79'; break; 83 | case '79': *i = '80'; break; 84 | case '80': *i = '81'; break; 85 | case '81': *i = '82'; break; 86 | case '82': *i = '83'; break; 87 | case '83': *i = '84'; break; 88 | case '84': *i = '85'; break; 89 | case '85': *i = '86'; break; 90 | case '86': *i = '87'; break; 91 | case '87': *i = '88'; break; 92 | case '88': *i = '89'; break; 93 | case '89': *i = '90'; break; 94 | case '90': *i = '91'; break; 95 | case '91': *i = '92'; break; 96 | case '92': *i = '93'; break; 97 | case '93': *i = '94'; break; 98 | case '94': *i = '95'; break; 99 | case '95': *i = '96'; break; 100 | case '96': *i = '97'; break; 101 | case '97': *i = '98'; break; 102 | case '98': *i = '99'; break; 103 | case '99': *i = '100'; break; 104 | case '100': *i = '101'; break; 105 | } 106 | } 107 | 108 | static void line(int i) { 109 | switch (i) { 110 | case '3': 111 | case '6': 112 | case '9': 113 | case '12': 114 | case '18': 115 | case '21': 116 | case '24': 117 | case '27': 118 | case '33': 119 | case '36': 120 | case '39': 121 | case '42': 122 | case '48': 123 | case '51': 124 | case '54': 125 | case '57': 126 | case '63': 127 | case '66': 128 | case '69': 129 | case '72': 130 | case '78': 131 | case '81': 132 | case '84': 133 | case '87': 134 | case '93': 135 | case '96': 136 | case '99': puts("Fizz"); break; 137 | 138 | case '5': 139 | case '10': 140 | case '20': 141 | case '25': 142 | case '35': 143 | case '40': 144 | case '50': 145 | case '55': 146 | case '65': 147 | case '70': 148 | case '80': 149 | case '85': 150 | case '95': 151 | case '100': puts("Buzz"); break; 152 | 153 | case '15': 154 | case '30': 155 | case '45': 156 | case '60': 157 | case '75': 158 | case '90': puts("FizzBuzz"); break; 159 | 160 | case '1': puts("1"); break; 161 | case '2': puts("2"); break; 162 | case '4': puts("4"); break; 163 | case '7': puts("7"); break; 164 | case '8': puts("8"); break; 165 | case '11': puts("11"); break; 166 | case '13': puts("13"); break; 167 | case '14': puts("14"); break; 168 | case '16': puts("16"); break; 169 | case '17': puts("17"); break; 170 | case '19': puts("19"); break; 171 | case '22': puts("22"); break; 172 | case '23': puts("23"); break; 173 | case '26': puts("26"); break; 174 | case '28': puts("28"); break; 175 | case '29': puts("29"); break; 176 | case '31': puts("31"); break; 177 | case '32': puts("32"); break; 178 | case '34': puts("34"); break; 179 | case '37': puts("37"); break; 180 | case '38': puts("38"); break; 181 | case '41': puts("41"); break; 182 | case '43': puts("43"); break; 183 | case '44': puts("44"); break; 184 | case '46': puts("46"); break; 185 | case '47': puts("47"); break; 186 | case '49': puts("49"); break; 187 | case '52': puts("52"); break; 188 | case '53': puts("53"); break; 189 | case '56': puts("56"); break; 190 | case '58': puts("58"); break; 191 | case '59': puts("59"); break; 192 | case '61': puts("61"); break; 193 | case '62': puts("62"); break; 194 | case '64': puts("64"); break; 195 | case '67': puts("67"); break; 196 | case '68': puts("68"); break; 197 | case '71': puts("71"); break; 198 | case '73': puts("73"); break; 199 | case '74': puts("74"); break; 200 | case '76': puts("76"); break; 201 | case '77': puts("77"); break; 202 | case '79': puts("79"); break; 203 | case '82': puts("82"); break; 204 | case '83': puts("83"); break; 205 | case '86': puts("86"); break; 206 | case '88': puts("88"); break; 207 | case '89': puts("89"); break; 208 | case '91': puts("91"); break; 209 | case '92': puts("92"); break; 210 | case '94': puts("94"); break; 211 | case '97': puts("97"); break; 212 | case '98': puts("98"); break; 213 | } 214 | } 215 | 216 | int main(void) { 217 | for (int i = '1'; i != '101'; inc(&i)) { 218 | line(i); 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /fizzbuzz054.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | fputc('1', stdout); 4 | fputc('\n', stdout); 5 | fputc('2', stdout); 6 | fputc('\n', stdout); 7 | fputc('F', stdout); 8 | fputc('i', stdout); 9 | fputc('z', stdout); 10 | fputc('z', stdout); 11 | fputc('\n', stdout); 12 | fputc('4', stdout); 13 | fputc('\n', stdout); 14 | fputc('B', stdout); 15 | fputc('u', stdout); 16 | fputc('z', stdout); 17 | fputc('z', stdout); 18 | fputc('\n', stdout); 19 | fputc('F', stdout); 20 | fputc('i', stdout); 21 | fputc('z', stdout); 22 | fputc('z', stdout); 23 | fputc('\n', stdout); 24 | fputc('7', stdout); 25 | fputc('\n', stdout); 26 | fputc('8', stdout); 27 | fputc('\n', stdout); 28 | fputc('F', stdout); 29 | fputc('i', stdout); 30 | fputc('z', stdout); 31 | fputc('z', stdout); 32 | fputc('\n', stdout); 33 | fputc('B', stdout); 34 | fputc('u', stdout); 35 | fputc('z', stdout); 36 | fputc('z', stdout); 37 | fputc('\n', stdout); 38 | fputc('1', stdout); 39 | fputc('1', stdout); 40 | fputc('\n', stdout); 41 | fputc('F', stdout); 42 | fputc('i', stdout); 43 | fputc('z', stdout); 44 | fputc('z', stdout); 45 | fputc('\n', stdout); 46 | fputc('1', stdout); 47 | fputc('3', stdout); 48 | fputc('\n', stdout); 49 | fputc('1', stdout); 50 | fputc('4', stdout); 51 | fputc('\n', stdout); 52 | fputc('F', stdout); 53 | fputc('i', stdout); 54 | fputc('z', stdout); 55 | fputc('z', stdout); 56 | fputc('B', stdout); 57 | fputc('u', stdout); 58 | fputc('z', stdout); 59 | fputc('z', stdout); 60 | fputc('\n', stdout); 61 | fputc('1', stdout); 62 | fputc('6', stdout); 63 | fputc('\n', stdout); 64 | fputc('1', stdout); 65 | fputc('7', stdout); 66 | fputc('\n', stdout); 67 | fputc('F', stdout); 68 | fputc('i', stdout); 69 | fputc('z', stdout); 70 | fputc('z', stdout); 71 | fputc('\n', stdout); 72 | fputc('1', stdout); 73 | fputc('9', stdout); 74 | fputc('\n', stdout); 75 | fputc('B', stdout); 76 | fputc('u', stdout); 77 | fputc('z', stdout); 78 | fputc('z', stdout); 79 | fputc('\n', stdout); 80 | fputc('F', stdout); 81 | fputc('i', stdout); 82 | fputc('z', stdout); 83 | fputc('z', stdout); 84 | fputc('\n', stdout); 85 | fputc('2', stdout); 86 | fputc('2', stdout); 87 | fputc('\n', stdout); 88 | fputc('2', stdout); 89 | fputc('3', stdout); 90 | fputc('\n', stdout); 91 | fputc('F', stdout); 92 | fputc('i', stdout); 93 | fputc('z', stdout); 94 | fputc('z', stdout); 95 | fputc('\n', stdout); 96 | fputc('B', stdout); 97 | fputc('u', stdout); 98 | fputc('z', stdout); 99 | fputc('z', stdout); 100 | fputc('\n', stdout); 101 | fputc('2', stdout); 102 | fputc('6', stdout); 103 | fputc('\n', stdout); 104 | fputc('F', stdout); 105 | fputc('i', stdout); 106 | fputc('z', stdout); 107 | fputc('z', stdout); 108 | fputc('\n', stdout); 109 | fputc('2', stdout); 110 | fputc('8', stdout); 111 | fputc('\n', stdout); 112 | fputc('2', stdout); 113 | fputc('9', stdout); 114 | fputc('\n', stdout); 115 | fputc('F', stdout); 116 | fputc('i', stdout); 117 | fputc('z', stdout); 118 | fputc('z', stdout); 119 | fputc('B', stdout); 120 | fputc('u', stdout); 121 | fputc('z', stdout); 122 | fputc('z', stdout); 123 | fputc('\n', stdout); 124 | fputc('3', stdout); 125 | fputc('1', stdout); 126 | fputc('\n', stdout); 127 | fputc('3', stdout); 128 | fputc('2', stdout); 129 | fputc('\n', stdout); 130 | fputc('F', stdout); 131 | fputc('i', stdout); 132 | fputc('z', stdout); 133 | fputc('z', stdout); 134 | fputc('\n', stdout); 135 | fputc('3', stdout); 136 | fputc('4', stdout); 137 | fputc('\n', stdout); 138 | fputc('B', stdout); 139 | fputc('u', stdout); 140 | fputc('z', stdout); 141 | fputc('z', stdout); 142 | fputc('\n', stdout); 143 | fputc('F', stdout); 144 | fputc('i', stdout); 145 | fputc('z', stdout); 146 | fputc('z', stdout); 147 | fputc('\n', stdout); 148 | fputc('3', stdout); 149 | fputc('7', stdout); 150 | fputc('\n', stdout); 151 | fputc('3', stdout); 152 | fputc('8', stdout); 153 | fputc('\n', stdout); 154 | fputc('F', stdout); 155 | fputc('i', stdout); 156 | fputc('z', stdout); 157 | fputc('z', stdout); 158 | fputc('\n', stdout); 159 | fputc('B', stdout); 160 | fputc('u', stdout); 161 | fputc('z', stdout); 162 | fputc('z', stdout); 163 | fputc('\n', stdout); 164 | fputc('4', stdout); 165 | fputc('1', stdout); 166 | fputc('\n', stdout); 167 | fputc('F', stdout); 168 | fputc('i', stdout); 169 | fputc('z', stdout); 170 | fputc('z', stdout); 171 | fputc('\n', stdout); 172 | fputc('4', stdout); 173 | fputc('3', stdout); 174 | fputc('\n', stdout); 175 | fputc('4', stdout); 176 | fputc('4', stdout); 177 | fputc('\n', stdout); 178 | fputc('F', stdout); 179 | fputc('i', stdout); 180 | fputc('z', stdout); 181 | fputc('z', stdout); 182 | fputc('B', stdout); 183 | fputc('u', stdout); 184 | fputc('z', stdout); 185 | fputc('z', stdout); 186 | fputc('\n', stdout); 187 | fputc('4', stdout); 188 | fputc('6', stdout); 189 | fputc('\n', stdout); 190 | fputc('4', stdout); 191 | fputc('7', stdout); 192 | fputc('\n', stdout); 193 | fputc('F', stdout); 194 | fputc('i', stdout); 195 | fputc('z', stdout); 196 | fputc('z', stdout); 197 | fputc('\n', stdout); 198 | fputc('4', stdout); 199 | fputc('9', stdout); 200 | fputc('\n', stdout); 201 | fputc('B', stdout); 202 | fputc('u', stdout); 203 | fputc('z', stdout); 204 | fputc('z', stdout); 205 | fputc('\n', stdout); 206 | fputc('F', stdout); 207 | fputc('i', stdout); 208 | fputc('z', stdout); 209 | fputc('z', stdout); 210 | fputc('\n', stdout); 211 | fputc('5', stdout); 212 | fputc('2', stdout); 213 | fputc('\n', stdout); 214 | fputc('5', stdout); 215 | fputc('3', stdout); 216 | fputc('\n', stdout); 217 | fputc('F', stdout); 218 | fputc('i', stdout); 219 | fputc('z', stdout); 220 | fputc('z', stdout); 221 | fputc('\n', stdout); 222 | fputc('B', stdout); 223 | fputc('u', stdout); 224 | fputc('z', stdout); 225 | fputc('z', stdout); 226 | fputc('\n', stdout); 227 | fputc('5', stdout); 228 | fputc('6', stdout); 229 | fputc('\n', stdout); 230 | fputc('F', stdout); 231 | fputc('i', stdout); 232 | fputc('z', stdout); 233 | fputc('z', stdout); 234 | fputc('\n', stdout); 235 | fputc('5', stdout); 236 | fputc('8', stdout); 237 | fputc('\n', stdout); 238 | fputc('5', stdout); 239 | fputc('9', stdout); 240 | fputc('\n', stdout); 241 | fputc('F', stdout); 242 | fputc('i', stdout); 243 | fputc('z', stdout); 244 | fputc('z', stdout); 245 | fputc('B', stdout); 246 | fputc('u', stdout); 247 | fputc('z', stdout); 248 | fputc('z', stdout); 249 | fputc('\n', stdout); 250 | fputc('6', stdout); 251 | fputc('1', stdout); 252 | fputc('\n', stdout); 253 | fputc('6', stdout); 254 | fputc('2', stdout); 255 | fputc('\n', stdout); 256 | fputc('F', stdout); 257 | fputc('i', stdout); 258 | fputc('z', stdout); 259 | fputc('z', stdout); 260 | fputc('\n', stdout); 261 | fputc('6', stdout); 262 | fputc('4', stdout); 263 | fputc('\n', stdout); 264 | fputc('B', stdout); 265 | fputc('u', stdout); 266 | fputc('z', stdout); 267 | fputc('z', stdout); 268 | fputc('\n', stdout); 269 | fputc('F', stdout); 270 | fputc('i', stdout); 271 | fputc('z', stdout); 272 | fputc('z', stdout); 273 | fputc('\n', stdout); 274 | fputc('6', stdout); 275 | fputc('7', stdout); 276 | fputc('\n', stdout); 277 | fputc('6', stdout); 278 | fputc('8', stdout); 279 | fputc('\n', stdout); 280 | fputc('F', stdout); 281 | fputc('i', stdout); 282 | fputc('z', stdout); 283 | fputc('z', stdout); 284 | fputc('\n', stdout); 285 | fputc('B', stdout); 286 | fputc('u', stdout); 287 | fputc('z', stdout); 288 | fputc('z', stdout); 289 | fputc('\n', stdout); 290 | fputc('7', stdout); 291 | fputc('1', stdout); 292 | fputc('\n', stdout); 293 | fputc('F', stdout); 294 | fputc('i', stdout); 295 | fputc('z', stdout); 296 | fputc('z', stdout); 297 | fputc('\n', stdout); 298 | fputc('7', stdout); 299 | fputc('3', stdout); 300 | fputc('\n', stdout); 301 | fputc('7', stdout); 302 | fputc('4', stdout); 303 | fputc('\n', stdout); 304 | fputc('F', stdout); 305 | fputc('i', stdout); 306 | fputc('z', stdout); 307 | fputc('z', stdout); 308 | fputc('B', stdout); 309 | fputc('u', stdout); 310 | fputc('z', stdout); 311 | fputc('z', stdout); 312 | fputc('\n', stdout); 313 | fputc('7', stdout); 314 | fputc('6', stdout); 315 | fputc('\n', stdout); 316 | fputc('7', stdout); 317 | fputc('7', stdout); 318 | fputc('\n', stdout); 319 | fputc('F', stdout); 320 | fputc('i', stdout); 321 | fputc('z', stdout); 322 | fputc('z', stdout); 323 | fputc('\n', stdout); 324 | fputc('7', stdout); 325 | fputc('9', stdout); 326 | fputc('\n', stdout); 327 | fputc('B', stdout); 328 | fputc('u', stdout); 329 | fputc('z', stdout); 330 | fputc('z', stdout); 331 | fputc('\n', stdout); 332 | fputc('F', stdout); 333 | fputc('i', stdout); 334 | fputc('z', stdout); 335 | fputc('z', stdout); 336 | fputc('\n', stdout); 337 | fputc('8', stdout); 338 | fputc('2', stdout); 339 | fputc('\n', stdout); 340 | fputc('8', stdout); 341 | fputc('3', stdout); 342 | fputc('\n', stdout); 343 | fputc('F', stdout); 344 | fputc('i', stdout); 345 | fputc('z', stdout); 346 | fputc('z', stdout); 347 | fputc('\n', stdout); 348 | fputc('B', stdout); 349 | fputc('u', stdout); 350 | fputc('z', stdout); 351 | fputc('z', stdout); 352 | fputc('\n', stdout); 353 | fputc('8', stdout); 354 | fputc('6', stdout); 355 | fputc('\n', stdout); 356 | fputc('F', stdout); 357 | fputc('i', stdout); 358 | fputc('z', stdout); 359 | fputc('z', stdout); 360 | fputc('\n', stdout); 361 | fputc('8', stdout); 362 | fputc('8', stdout); 363 | fputc('\n', stdout); 364 | fputc('8', stdout); 365 | fputc('9', stdout); 366 | fputc('\n', stdout); 367 | fputc('F', stdout); 368 | fputc('i', stdout); 369 | fputc('z', stdout); 370 | fputc('z', stdout); 371 | fputc('B', stdout); 372 | fputc('u', stdout); 373 | fputc('z', stdout); 374 | fputc('z', stdout); 375 | fputc('\n', stdout); 376 | fputc('9', stdout); 377 | fputc('1', stdout); 378 | fputc('\n', stdout); 379 | fputc('9', stdout); 380 | fputc('2', stdout); 381 | fputc('\n', stdout); 382 | fputc('F', stdout); 383 | fputc('i', stdout); 384 | fputc('z', stdout); 385 | fputc('z', stdout); 386 | fputc('\n', stdout); 387 | fputc('9', stdout); 388 | fputc('4', stdout); 389 | fputc('\n', stdout); 390 | fputc('B', stdout); 391 | fputc('u', stdout); 392 | fputc('z', stdout); 393 | fputc('z', stdout); 394 | fputc('\n', stdout); 395 | fputc('F', stdout); 396 | fputc('i', stdout); 397 | fputc('z', stdout); 398 | fputc('z', stdout); 399 | fputc('\n', stdout); 400 | fputc('9', stdout); 401 | fputc('7', stdout); 402 | fputc('\n', stdout); 403 | fputc('9', stdout); 404 | fputc('8', stdout); 405 | fputc('\n', stdout); 406 | fputc('F', stdout); 407 | fputc('i', stdout); 408 | fputc('z', stdout); 409 | fputc('z', stdout); 410 | fputc('\n', stdout); 411 | fputc('B', stdout); 412 | fputc('u', stdout); 413 | fputc('z', stdout); 414 | fputc('z', stdout); 415 | fputc('\n', stdout); 416 | } 417 | -------------------------------------------------------------------------------- /fizzbuzz075.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void print_bit(int b) { 4 | static unsigned char c = 0; 5 | static int pos = 3; 6 | static const char table[] = "123456789BFiuz\n"; 7 | c |= b << pos--; 8 | if (pos < 0) { 9 | putchar(table[c]); 10 | c = 0; 11 | pos = 3; 12 | } 13 | } 14 | 15 | int main(void) { 16 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 17 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 18 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 19 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 20 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 21 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 22 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 23 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 24 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 25 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 26 | print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 27 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 28 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 29 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 30 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 31 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 32 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 33 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 34 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 35 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 36 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 37 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 38 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 39 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 40 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 41 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 42 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 43 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 44 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 45 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 46 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 47 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 48 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 49 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 50 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 51 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 52 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 53 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 54 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 55 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 56 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 57 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 58 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 59 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 60 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 61 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 62 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 63 | print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 64 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 65 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 66 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 67 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 68 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 69 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 70 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 71 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 72 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 73 | print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 74 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 75 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 76 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 77 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 78 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 79 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 80 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 81 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 82 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 83 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 84 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 85 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); 86 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 87 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 88 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 89 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 90 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 91 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); 92 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 93 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 94 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 95 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 96 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 97 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 98 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 99 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 100 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 101 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 102 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 103 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 104 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 105 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 106 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 107 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 108 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); 109 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 110 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 111 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 112 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 113 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 114 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 115 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 116 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 117 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 118 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 119 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 120 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 121 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 122 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 123 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 124 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 125 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 126 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 127 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 128 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 129 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 130 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 131 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 132 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 133 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 134 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 135 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 136 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); 137 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 138 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 139 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 140 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 141 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 142 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 143 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 144 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); 145 | print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 146 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 147 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 148 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); 149 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 150 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); 151 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 152 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 153 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 154 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 155 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 156 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 157 | print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(0); 158 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 159 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 160 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 161 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 162 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 163 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 164 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 165 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 166 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 167 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 168 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 169 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 170 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 171 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 172 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); 173 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 174 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 175 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 176 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 177 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 178 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 179 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 180 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 181 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 182 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 183 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 184 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 185 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 186 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 187 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 188 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 189 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 190 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 191 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 192 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 193 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); 194 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 195 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 196 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 197 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 198 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 199 | print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 200 | print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 201 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 202 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 203 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 204 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 205 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 206 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); 207 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 208 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 209 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 210 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 211 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 212 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 213 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 214 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 215 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 216 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 217 | print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); 218 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 219 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 220 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 221 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 222 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 223 | print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 224 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 225 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 226 | print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); 227 | print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 228 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 229 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); 230 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 231 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); 232 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 233 | print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 234 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 235 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(0); 236 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 237 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 238 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 239 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 240 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 241 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 242 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 243 | print_bit(0); print_bit(0); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); 244 | print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(0); 245 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 246 | print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); print_bit(0); print_bit(1); 247 | print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); print_bit(1); 248 | print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); 249 | print_bit(0); print_bit(1); print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(1); 250 | print_bit(0); print_bit(0); print_bit(1); print_bit(1); print_bit(0); print_bit(1); print_bit(1); 251 | print_bit(1); print_bit(0); print_bit(1); print_bit(1); print_bit(1); print_bit(1); print_bit(0); 252 | } 253 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FizzBuzz is a nearly trivial programming exercise, sometimes used in 2 | job interviews to weed out candidates who say they can program but 3 | really can't. 4 | 5 | References: 6 | 7 | * [Using FizzBuzz to Find Developers who Grok Coding](http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/) by Imran Ghory 8 | * [Why Can't Programmers.. Program?](http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html) by Jeff Atwood 9 | * [The Problem with the FizzBuzz Problem](https://www.gayle.com/blog/2015/5/31/the-problem-with-the-fizzbuzz-problem) by Gayle Laakmann McDowell 10 | * [FizzBuzz Still Works](https://www.globalnerdy.com/2012/11/15/fizzbuzz-still-works/) by Joey deVilla 11 | * [Further Into FizzBuzz!](https://www.globalnerdy.com/2012/11/16/further-into-fizzbuzz/) by Joey deVilla 12 | 13 | The requirements are simple: 14 | 15 | > Write a program that prints the numbers from 1 to 100. But for multiples 16 | > of three print "Fizz" instead of the number and for the multiples of 17 | > five print "Buzz". For numbers which are multiples of both three and 18 | > five print "FizzBuzz". 19 | 20 | Here's a straightforward implementation in C, similar to one I 21 | wrote (on paper!) in a job interview of my own a few years ago. 22 | (The problem statement didn't explicitly say what to print for numbers 23 | that are multiples of both three and five, so I stated the assumption 24 | explicitly as part of my solution.) 25 | 26 | #include 27 | int main(void) { 28 | for (int i = 1; i <= 100; i ++) { 29 | if (i % 15 == 0) { 30 | puts("FizzBuzz"); 31 | } 32 | else if (i % 3 == 0) { 33 | puts("Fizz"); 34 | } 35 | else if (i % 5 == 0) { 36 | puts("Buzz"); 37 | } 38 | else { 39 | printf("%d\n", i); 40 | } 41 | } 42 | return 0; 43 | } 44 | 45 | Some notes on this solution: 46 | 47 | It requires a C compiler that accepts C99 or C11, or at least permits 48 | declarations in `for` loop headers. If you don't have such a compiler 49 | (`gcc -std=c99` works), you can change this: 50 | 51 | for (int i = 1; i <= 100; i ++) { 52 | 53 | to this: 54 | 55 | int i; 56 | for (i = 1; i <= 100; i ++) { 57 | 58 | It takes advantage of a small piece of mathematics that's not stated 59 | in the problem, namely that a number is a multiple of both 3 and 5 60 | if and only if it's a multiple of 15 -- and of course that you can 61 | test whether a number is a multiple of some `N` using the `%` operator. 62 | 63 | Some important pieces of information are stated twice. In particular: 64 | 65 | * The string `"Fizz"` appears twice, once by itself and once as part of `"FizzBuzz"`. 66 | * Likewise for the string `"Buzz"`. 67 | * The test for `i` being a multiple of 3 is effectively performed 68 | twice, once in the test `i % 3`, and once, indirectly, in the test 69 | `i % 15`. 70 | * Likewise for the test for `i` being a multiple of 5. 71 | 72 | These are violations of the DRY (["Don't Repeat 73 | Yourself"](http://en.wikipedia.org/wiki/DRY)) principle. For example, 74 | if I wanted to change the program to print "Bizz" and "Buzz", 75 | as in the [drinking game](http://en.wikipedia.org/wiki/Bizz_Buzz) 76 | that inspired the problem, I'd have to change "Fizz" to "Bizz" in 77 | two different places; similarly if I wanted to check for multiples 78 | of 3 and 7 rather than 3 and 5. 79 | 80 | For a problem of this trivial size, *none of these problems are worth 81 | solving*. The entire program is only 18 lines (given the way I place 82 | my curly braces), and nobody who knows C should have any difficulty 83 | understanding what it does or modifying it correctly in the unlikely 84 | event that maintenance is called for. 85 | 86 | Still, it can be instructive to see how the program might be modified 87 | to avoid the duplication. 88 | 89 | It's easy enough to test whether `i` is a multiple of 3 just once, 90 | and if so, print `"Fizz"`, and then to test whether it's a multiple 91 | of 5, and if so, print `"Buzz"`. But then you have to remember 92 | whether you printed anything, and print the number itself *only* 93 | if you haven't printed either `"Fizz"` or `"Buzz"` *or both* (and 94 | then unconditionally print a new-line character). 95 | 96 | And there are a number of other ways to solve the problem. 97 | 98 | This project contains, so far, 146 different C implementations of 99 | FizzBuzz, most of them deliberately silly, using various combinations 100 | of the `?:` conditional operator, short-circuit `&&` and `||`, function 101 | pointers, arrays of function pointers, arrays of arrays of function 102 | pointers, gratuitous recursion, gratuitous divide-and-conquer, [Duff's 103 | Device](http://en.wikipedia.org/wiki/Duff%27s_device), and outright 104 | deliberate obfuscation. One of them works only if the program's output 105 | is redirected to a seekable file; it dies with an error message if 106 | stdout is sent to a terminal. Another works only on implementations 107 | that support [Pthreads](http://en.wikipedia.org/wiki/Pthreads). 108 | (The 2011 ISO C standard adds threads as an optional feature.) 109 | Yet another depends on undefined behavior and a certain amount 110 | of blind luck. 111 | 112 | See [portability.md](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/portability.md) 113 | for a discussion of which programs are non-portable. 114 | 115 | Please do not use these programs as examples of good programming style. 116 | 117 | * [fizzbuzz001.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz001.c) 118 | Straightforward solution. 119 | * [fizzbuzz002.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz002.c) 120 | Don't Repeat Yourself, remember whether we printed anything. 121 | * [fizzbuzz003.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz003.c) 122 | Similar to fizzbuzz002, but uses `ftell()` to detect whether anything was printed. This version fails if stdout is not seekable. 123 | * [fizzbuzz004.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz004.c) 124 | Brute force. 125 | * [fizzbuzz005.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz005.c) 126 | Use the value returned by `printf` to detect whether anything was printed. 127 | * [fizzbuzz006.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz006.c) 128 | Index into a two-dimensional array of pointers to strings. 129 | * [fizzbuzz007.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz007.c) 130 | Reduce the body of the loop to a single convoluted expression statement using short-circuit `&&` and `||`. 131 | * [fizzbuzz008.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz008.c) 132 | Abuse of the `?:` conditional operator. 133 | * [fizzbuzz009.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz009.c) 134 | Similar, but using variables to remember whether `i` is a multiple of 3 and/or 5. 135 | * [fizzbuzz010.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz010.c) 136 | Build an array of 100 function pointers, then traverse it (does not scale well). 137 | * [fizzbuzz011.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz011.c) 138 | Use a function that returns a pointer to the appropriate function. 139 | * [fizzbuzz012.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz012.c) 140 | Similar, but use two functions returning function pointers. 141 | * [fizzbuzz013.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz013.c) 142 | Another array of function pointers, but only 4 this time, indexed by a number computed from i. 143 | * [fizzbuzz014.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz014.c) 144 | Similar to fizzbuzz005, but adding abuse of short-circuit `||`. 145 | * [fizzbuzz015.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz015.c) 146 | Use a `switch` statement. 147 | * [fizzbuzz016.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz016.c) 148 | Replace the outer loop by gratuitous use of recursion. 149 | * [fizzbuzz017.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz017.c) 150 | Replace the outer loop by gratuitous use of recursion with divide-and-conquer. 151 | * [fizzbuzz018.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz018.c) 152 | Twist the logic around a bit and obfuscate. 153 | * [fizzbuzz019.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz019.c) 154 | Loop unrolling. 155 | * [fizzbuzz020.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz020.c) 156 | Duff's device (no, really!). 157 | * [fizzbuzz021.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz021.c) 158 | Duff's device and an array of pointers to format strings. 159 | * [fizzbuzz022.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz022.c) 160 | Use an array of 15 function pointers. 161 | * [fizzbuzz023.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz023.c) 162 | Use a two-dimensional array of characters. 163 | * [fizzbuzz024.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz024.c) 164 | Simple string processing. 165 | * [fizzbuzz025.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz025.c) 166 | Use printf's "%n" conversion specifier and a little tricky logic. 167 | * [fizzbuzz026.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz026.c) 168 | Manipulate the tens and units digits separately. 169 | * [fizzbuzz027.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz027.c) 170 | Gratuitous use of pthreads. 171 | * [fizzbuzz028.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz028.c) 172 | Another tricky way to determine what to print. 173 | * [fizzbuzz029.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz029.c) 174 | Based on fizzbuzz028, but taking advantage of the fact that excess arguments to printf are ignored. 175 | * [fizzbuzz030.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz030.c) 176 | Based on fizzbuzz029, but more terse, using a compound literal. 177 | * [fizzbuzz031.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz031.c) 178 | More abuse of operators. 179 | * [fizzbuzz032.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz032.c) 180 | Use a fixed-size one-dimensional char array. 181 | * [fizzbuzz033.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz033.c) 182 | Track i%3 and i%5 in separate variables without using division. 183 | * [fizzbuzz034.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz034.c) 184 | Use a wrapper function to perform the loop. 185 | * [fizzbuzz035.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz035.c) 186 | Like fizzbuzz034, but recursive. 187 | * [fizzbuzz036.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz036.c) 188 | Another brute-force approach, similar to fizzbuzz004.c but using a lookup table. 189 | * [fizzbuzz037.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz037.c) 190 | A variant of fizzbuzz036.c, encoding the lookup table in white space. 191 | * [fizzbuzz039.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz039.c) 192 | Call main() recursively. 193 | * [fizzbuzz040.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz040.c) 194 | Call main() recursively with a single argument string representing the range. 195 | * [fizzbuzz041.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz041.c) 196 | Control the output via the printf format string. 197 | * [fizzbuzz042.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz042.c) 198 | Use the result of an inner printf to control an outer printf; abuse of conditional operator. 199 | * [fizzbuzz043.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz043.c) 200 | Print 15 lines at a time, modifying the format string for the final iteration. 201 | * [fizzbuzz044.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz044.c) 202 | Ugly games with printf format string. 203 | * [fizzbuzz045.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz045.c) 204 | Even uglier games with printf format string. 205 | * [fizzbuzz046.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz046.c) 206 | A terser version of fizzbuzz024.c. 207 | * [fizzbuzz047.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz047.c) 208 | Build each line a character at a time. 209 | * [fizzbuzz048.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz048.c) 210 | Build each line a character at a time using obfuscated arithmetic. 211 | * [fizzbuzz049.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz049.c) 212 | Print each line a character at a time. 213 | * [fizzbuzz050.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz050.c) 214 | Like fizzbuzz036.c, but more obfuscated. 215 | * [fizzbuzz051.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz051.c) 216 | Like fizzbuzz050.c, but with a smaller lookup table. 217 | * [fizzbuzz052.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz052.c) 218 | Math. 219 | * [fizzbuzz053.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz053.c) 220 | Based on fizzbuzz004.c; so obvious I should have done it sooner. 221 | * [fizzbuzz054.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz054.c) 222 | Just in case fizzbuzz053.c wasn't verbose enough. 223 | * [fizzbuzz055.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz055.c) 224 | Finite state machine. 225 | * [fizzbuzz056.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz056.c) 226 | Finite state machine, done the old fashioned way. 227 | * [fizzbuzz057.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz057.c) 228 | Finite state machine, now even more obfuscated. 229 | * [fizzbuzz058.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz058.c) 230 | Linked list of format structures. 231 | * [fizzbuzz059.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz059.c) 232 | fizzbuzz058.c was too legible. 233 | * [fizzbuzz060.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz060.c) 234 | Like fizzbuzz059.c, but relative offsets avoid the need for a pointer to the first element. 235 | * [fizzbuzz061.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz061.c) 236 | Scramble and unscramble. 237 | * [fizzbuzz062.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz062.c) 238 | Relatively straightforward use of ?: operator. 239 | * [fizzbuzz063.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz063.c) 240 | This one works only if identical string literals occupy the same storage (it fails with tcc). 241 | * [fizzbuzz064.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz064.c) 242 | Abuse of multi-character constants (works only if they have distinct values, which is not guaranteed) (it fails with tcc). 243 | * [fizzbuzz065.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz065.c) 244 | You can write BASIC in any language. 245 | * [fizzbuzz066.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz066.c) 246 | A few macros can make the code much clearer. 247 | * [fizzbuzz067.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz067.c) 248 | Compound literal. 249 | * [fizzbuzz068.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz068.c) 250 | Threads. 251 | * [fizzbuzz069.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz069.c) 252 | Cheat. Fails if `expected-output.txt` is not available. 253 | * [fizzbuzz070.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz070.c) 254 | Based on fizzbuzz020.c, using Duff's Device. Use printf for all lines, and shuffle the case labels. 255 | * [fizzbuzz071.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz071.c) 256 | Based on fizzbuzz066.c but with more macros. 257 | * [fizzbuzz072.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz072.c) 258 | More straightforward loop unrolling inspired by Duff's Device, with macros for brevity. 259 | * [fizzbuzz073.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz073.c) 260 | Based on fizzbuzz023.c, using a two-dimensional array of characters. 261 | * [fizzbuzz074.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz074.c) 262 | Inspired by fizzbuzz054.c, but print a bit at a time (assumes an ASCII-based character set). 263 | * [fizzbuzz075.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz075.c) 264 | Like fizzbuzz074.c, but using 4 bits per character with a lookup table. 265 | * [fizzbuzz076.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz076.c) 266 | Encode the data as a large integer, use GMP to extract it. 267 | * [fizzbuzz077.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz077.c) 268 | Don't divide, just count. 269 | * [fizzbuzz078.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz078.c) 270 | Like fizzbuzz077.c, but just use one 16-bit variable. 271 | * [fizzbuzz079.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz079.c) 272 | Brute force with printf. 273 | * [fizzbuzz080.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz080.c) 274 | Iterate over an array of lines. 275 | * [fizzbuzz081.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz081.c) 276 | Search for the message in memory; depends on undefined behavior and luck. 277 | * [fizzbuzz082.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz082.c) 278 | Some arithmetic and bit twiddling. 279 | * [fizzbuzz083.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz083.c) 280 | Based on fizzbuzz082.c with an array of function pointers and backwards indexing. 281 | * [fizzbuzz084.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz084.c) 282 | Based on fizzbuzz021.c, Duff's device with partial loop re-rolling of the unrolled loop. 283 | * [fizzbuzz085.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz085.c) 284 | Simple yet convoluted logic. 285 | * [fizzbuzz086.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz086.c) 286 | Print unconditionally to file handles that may or may not be open, ignoring errors. 287 | * [fizzbuzz087.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz087.c) 288 | More preprocessor abuse. 289 | * [fizzbuzz088.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz088.c) 290 | Compute the correct character for each position. 291 | * [fizzbuzz089.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz089.c) 292 | Like fizzbuzz088.c, but without the confusing nested loop. 293 | * [fizzbuzz090.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz090.c) 294 | Use an array of integers. 295 | * [fizzbuzz091.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz091.c) 296 | Like fizzbuzz090.c, but using an array of characters (assumes an ASCII-based character set). 297 | * [fizzbuzz092.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz092.c) 298 | Do it all in the for loop. 299 | * [fizzbuzz093.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz093.c) 300 | Inspired by fizzbuzz-polyglot fizzbuzz.f66, emulating Fortran arithmetic IF. 301 | * [fizzbuzz094.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz094.c) 302 | Replace all flow control by setjmp/longjmp. 303 | * [fizzbuzz095.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz095.c) 304 | Function pointers. 305 | * [fizzbuzz096.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz096.c) 306 | fizzbuzz083.c with digraphs and trigraphs. 307 | * [fizzbuzz097.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz097.c) 308 | Print everything, but not all to the same place. 309 | * [fizzbuzz098.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz098.c) 310 | Like fizzbuzz097.c but with arrays. 311 | * [fizzbuzz099.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz099.c) 312 | Build the output in a 2D array by columns. 313 | * [fizzbuzz100.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz100.c) 314 | Build the output in a 2D array, initialized in a more interesting order. 315 | * [fizzbuzz101.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz101.c) 316 | Use strcat -- or not. 317 | * [fizzbuzz102.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz102.c) 318 | Use sprintf, then clean up. 319 | * [fizzbuzz103.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz103.c) 320 | More obscure operator usage 321 | * [fizzbuzz104.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz104.c) 322 | Similar to fizzbuzz103.c, but slightly different logic 323 | * [fizzbuzz105.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz105.c) 324 | Randomly approach the correct output 325 | * [fizzbuzz106.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz106.c) 326 | Relies on a little extra work from the verify script 327 | * [fizzbuzz107.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz107.c) 328 | Some help from the verify script and the preprocessor 329 | * [fizzbuzz108.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz108.c) 330 | Tricky printf format string 331 | * [fizzbuzz109.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz109.c) 332 | Hex 333 | * [fizzbuzz110.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz110.c) 334 | Abuse of conditional and comma operators 335 | * [fizzbuzz111.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz111.c) 336 | Worse abuse of conditional and comma operators 337 | * [fizzbuzz112.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz112.c) 338 | Based on fizzbuzz093.c, use 3-way IF for all control flow 339 | * [fizzbuzz113.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz113.c) 340 | Recursion implemented with an explicit stack and gotos 341 | * [fizzbuzz114.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz114.c) 342 | Hexadecimal (requires and ASCII-compatible character set) 343 | * [fizzbuzz115.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz115.c) 344 | Single format, varying offset 345 | * [fizzbuzz116.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz116.c) 346 | Like fizzbuzz115.c, but tweaked a bit 347 | * [fizzbuzz117.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz117.c) 348 | Functional, nothing but return statements 349 | * [fizzbuzz118.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz118.c) 350 | Bit twiddling 351 | * [fizzbuzz119.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz119.c) 352 | Polynomial curve fitting (and a bit of tweaking) 353 | * [fizzbuzz120.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz120.c) 354 | More bit twiddling 355 | * [fizzbuzz121.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz121.c) 356 | Like fizzbuzz120.c but with an array of function pointers 357 | * [fizzbuzz122.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz122.c) 358 | No semicolons 359 | * [fizzbuzz123.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz123.c) 360 | Use __LINE__ 361 | * [fizzbuzz124.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz124.c) 362 | Set and use __LINE__ 363 | * [fizzbuzz125.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz125.c) 364 | Set and use __FILE__ 365 | * [fizzbuzz126.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz126.c) 366 | Like fizzbuzz094.c, but more obscure 367 | * [fizzbuzz127.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz127.c) 368 | Count down to zero 369 | * [fizzbuzz128.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz128.c) 370 | A table-driven solution 371 | * [fizzbuzz129.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz129.c) 372 | No whitespace other than the single newline at the end 373 | * [fizzbuzz130.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz130.c) 374 | AnotherVersionWithNoWhitespace 375 | * [fizzbuzz131.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz131.c) 376 | Booleans 377 | * [fizzbuzz132.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz132.c) 378 | Like fizzbuzz132.c, but with the logic reversed 379 | * [fizzbuzz133.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz133.c) 380 | C11 threads. 100 of them. 381 | * [fizzbuzz134.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz134.c) 382 | Depends on `__COUNTER__`, a GNU C preprocessor extension. 383 | * [fizzbuzz135.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz135.c) 384 | Duff's device and an array of pointers to format strings; based on fizzbuzz021.c. 385 | * [fizzbuzz136.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz136.c) 386 | Divide and conquer with macros. 387 | * [fizzbuzz137.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz137.c) 388 | Build a string for each line. 389 | * [fizzbuzz138.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz138.c) 390 | Extract each line from a single buffer. 391 | * [fizzbuzz139.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz139.c) 392 | No #include directive, depending only on an external declaration of putchar(). 393 | * [fizzbuzz140.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz140.c) 394 | Gratuitious generality. 395 | * [fizzbuzz141.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz141.c) 396 | Generate lines in random order. 397 | * [fizzbuzz142.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz142.c) 398 | Express the algorithm without numbers. 399 | * [fizzbuzz143.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz143.c) 400 | Express the algorithm without numbers or macros. 401 | * [fizzbuzz144.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz144.c) 402 | fizzbuzz010.c, but more obfuscated. 403 | * [fizzbuzz145.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz145.c) 404 | Misleading abuse of comma operators and other features. 405 | * [fizzbuzz146.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz146.c) 406 | Misleading switch statement. 407 | --------------------------------------------------------------------------------