/* * Completely division-free, strlen-free, (hopefully) warning-free, * and (hopefully) error-free implementation of Hoppity Hop. :-) * Copyright (c) 2009 Chris K. Jester-Young; GPLv3+. */ #include static const char text[] = "Hoppity\nHophop\nHoppity\nHoppity\nHophop\nHoppity\nHop\n"; static const size_t offs[] = {0, 0, 0, 8, 8, 15, 23, 23, 23, 31, 38, 38, 46, 46, 46}; static size_t put(size_t len) { return fwrite(text, len, 1, stdout); } int main(int argc, char **argv) { unsigned int n; FILE *fp; if (argc < 2 || !(fp = fopen(argv[1], "r")) || !fscanf(fp, "%u", &n)) return 1; fclose(fp); for (; n >= 15; n -= 15) put(sizeof text - 1); put(offs[n]); return 0; }