Skip to content

Instantly share code, notes, and snippets.

@grantslatton
Last active August 19, 2022 11:20
Show Gist options
  • Save grantslatton/7187941 to your computer and use it in GitHub Desktop.
Save grantslatton/7187941 to your computer and use it in GitHub Desktop.

Revisions

  1. grantslatton revised this gist Oct 28, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fizzbuzz.c
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ int t0(unsigned int x) { return x? (x&(1<<31)? t1(x<<1) : t0(x<<1)) : 1; }
    int t1(unsigned int x) { return x? (x&(1<<31)? t0(x<<1) : t2(x<<1)) : 0; }
    int t2(unsigned int x) { return x? (x&(1<<31)? t2(x<<1) : t1(x<<1)) : 0; }

    void main() {
    int main(void) {
    unsigned int i;
    for(i=1; i <= 100; i++) {
    if(t0(i)) printf("Fizz");
  2. grantslatton created this gist Oct 27, 2013.
    20 changes: 20 additions & 0 deletions fizzbuzz.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #include <stdio.h>
    int f0(unsigned int x) { return x? (x&(1<<31)? f1(x<<1) : f0(x<<1)) : 1; }
    int f1(unsigned int x) { return x? (x&(1<<31)? f3(x<<1) : f2(x<<1)) : 0; }
    int f2(unsigned int x) { return x? (x&(1<<31)? f0(x<<1) : f4(x<<1)) : 0; }
    int f3(unsigned int x) { return x? (x&(1<<31)? f2(x<<1) : f1(x<<1)) : 0; }
    int f4(unsigned int x) { return x? (x&(1<<31)? f4(x<<1) : f3(x<<1)) : 0; }

    int t0(unsigned int x) { return x? (x&(1<<31)? t1(x<<1) : t0(x<<1)) : 1; }
    int t1(unsigned int x) { return x? (x&(1<<31)? t0(x<<1) : t2(x<<1)) : 0; }
    int t2(unsigned int x) { return x? (x&(1<<31)? t2(x<<1) : t1(x<<1)) : 0; }

    void main() {
    unsigned int i;
    for(i=1; i <= 100; i++) {
    if(t0(i)) printf("Fizz");
    if(f0(i)) printf("Buzz");
    if(!(t0(i)|f0(i))) printf("%u",i);
    printf("\n");
    }
    }