summaryrefslogblamecommitdiffstats
path: root/inf/aoc/2.1.c
blob: 76d4d537b0c7c447eb1173a1ade7576614faba7f (plain) (tree)























































                                                       
#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 += 1;
				switch (buf[0]) {
					case 'A':
						t += 3;
						break;
					case 'B':
						t += 0;
						break;
					case 'C':
						t += 6;
						break;
				}
				break;
			case 'Y':
				t += 2;
				switch (buf[0]) {
					case 'A':
						t += 6;
						break;
					case 'B':
						t += 3;
						break;
					case 'C':
						t += 0;
						break;
				}
				break;
			case 'Z':
				t += 3;
				switch (buf[0]) {
					case 'A':
						t += 0;
						break;
					case 'B':
						t += 6;
						break;
					case 'C':
						t += 3;
						break;
				}
				break;
		}
	}
	printf("%d\n", t);
}