uppga.c (750B)
1 #include "common.h" 2 3 // I really don't want to parse this from input 4 uint64_t operation(uint64_t x, size_t i) { 5 if (i == 0) { 6 return (x * 7) / 3; 7 } else if (i == 1) { 8 return (x * 13) / 3; 9 } else if (i == 2) { 10 return (x + 1) / 3; 11 } else if (i == 3) { 12 return (x * x) / 3; 13 } else if (i == 4) { 14 return (x + 7) / 3; 15 } else if (i == 5) { 16 return (x + 6) / 3; 17 } else if (i == 6) { 18 return (x + 4) / 3; 19 } 20 return (x + 8) / 3; 21 } 22 23 int main(int argc, char **argv) { 24 char **lines; 25 size_t nlines = readlines(&lines, "input"); 26 27 monkis m = parse_monkis(lines, nlines, 0); 28 m.operate = operation; 29 30 size_t i; 31 for (i = 0; i < 20; i++) 32 mround(m); 33 34 printf("%llu\n", get_result(m)); 35 36 let_the_monkis_out(m); 37 }