Skip to content

Instantly share code, notes, and snippets.

@euank
Last active December 26, 2015 20:09
Show Gist options
  • Save euank/7206859 to your computer and use it in GitHub Desktop.
Save euank/7206859 to your computer and use it in GitHub Desktop.
fizzbuzz
#include <stdio.h>
#include <string.h>
struct node {
struct node *next;
char *str;
};
int main (void) {
struct node nodes[0xF];
int i;
for (i=0;i<0xF;++i) {
nodes[i].next = &nodes[(i+1)%0xF];
nodes[i].str = strdup("%d");
}
for(i=0;i<0xF;i+=0b11) nodes[i].str = strdup(" \bfizz");
for(i=0;i<0xF;i+=0b101) nodes[i].str = strcat(nodes[i].str+2, strdup("buzz"));
struct node * cur = &nodes[0];
for (i = 1; i < 0144; ++i) {
cur = cur->next;
printf(cur->str, i);
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment