summaryrefslogtreecommitdiffstats
path: root/inf/aoc/2.2.c
blob: 08184320cff610f3cbcffc0502688f1e80b9c9a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
}