Skip to content

Instantly share code, notes, and snippets.

@johnclaus
Created April 18, 2011 06:59
Show Gist options
  • Save johnclaus/924916 to your computer and use it in GitHub Desktop.
Save johnclaus/924916 to your computer and use it in GitHub Desktop.
Refreshing my memory of C I/O against FB's take on FizzBuzz
// Solution to https://www.facebook.com/careers/puzzles.php?puzzle_id=7
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int x, y;
if (argc == 1) {
printf("Filename argument required\n");
exit(1);
}
freopen(argv[1], "r", stdin);
scanf("%d", &x);
for(y = 1; y <=x; y++) {
if (y % 3 == 0 && y % 5 == 0) { printf("Hop\n"); }
else if (y % 3 == 0) { printf("Hoppity\n"); }
else if(y % 5 == 0) { printf("Hophop\n"); }
}
}
@apg
Copy link

apg commented Apr 18, 2011

this should have been done using HipHop.

@johnclaus
Copy link
Author

Why's that?

@apg
Copy link

apg commented Apr 18, 2011

Just because of what it prints. Hop, Hoppity, Hophop. If it was done using HipHop, it'd be Hip Hoppity HopHop, which sounds funny as hell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment