aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2022/02/2.c
diff options
context:
space:
mode:
Diffstat (limited to 'advent-of-code/2022/02/2.c')
-rw-r--r--advent-of-code/2022/02/2.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/advent-of-code/2022/02/2.c b/advent-of-code/2022/02/2.c
deleted file mode 100644
index 5ec98ec..0000000
--- a/advent-of-code/2022/02/2.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define BUFSZ 1024
-
-char buf[BUFSZ];
-int valuetbl[3] = {1, 2, 3};
-int wintbl[3][3] = {
- {3, 6, 0},
- {0, 3, 6},
- {6, 0, 3}
-};
-char decodetbl[3][3] = {
- {'C', 'A', 'B'},
- {'A', 'B', 'C'},
- {'B', 'C', 'A'}
-};
-
-
-int score(char a, char b) {
- b = decodetbl[a - 'A'][b - 'X'];
- return valuetbl[b - 'A'] + wintbl[a - 'A'][b - 'A'];
-}
-
-int main() {
- FILE *fp = fopen("input", "r");
- if (fp == NULL) return -1;
- int scr = 0;
- while (fgets(buf, BUFSZ, fp)) {
- if (strlen(buf) <= 1) continue;
- scr += score(buf[0], buf[2]);
- }
- printf("%d\n", scr);
- return 0;
-}