Created
April 18, 2011 06:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); } | |
} | |
} |
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
Why's that?