diff options
Diffstat (limited to 'inf/aoc/2.2.c')
-rw-r--r-- | inf/aoc/2.2.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/inf/aoc/2.2.c b/inf/aoc/2.2.c new file mode 100644 index 0000000..0818432 --- /dev/null +++ b/inf/aoc/2.2.c @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdlib.h> +int main (void) { + int t = 0; + while (1) { + char buf[8]; + fgets(buf, 8, stdin); + if (ferror(stdin) || feof(stdin)) + break; + switch (buf[2]) { + case 'X': + t += 0; + switch (buf[0]) { + case 'A': + t += 3; + break; + case 'B': + t += 1; + break; + case 'C': + t += 2; + break; + } + break; + case 'Y': + t += 3; + switch (buf[0]) { + case 'A': + t += 1; + break; + case 'B': + t += 2; + break; + case 'C': + t += 3; + break; + } + break; + case 'Z': + t += 6; + switch (buf[0]) { + case 'A': + t += 2; + break; + case 'B': + t += 3; + break; + case 'C': + t += 1; + break; + } + break; + } + } + printf("%d\n", t); +} |