This commit is contained in:
Evan Burkey 2022-12-07 14:57:27 +01:00
parent 3fdfd035b1
commit bb8dbf7b5c

View File

@ -1,10 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lfinput.h"
int sc2202[3][3] = {
{4, 8, 3},
{1, 5, 9},
{7, 2, 6}
};
int sc2202p2[3][3] = {
{3, 4, 8},
{1, 5, 9},
{2, 6, 7}
};
void advent2022day02(void) {
char *input = get_input("input/2022/02");
printf("Solution for Day 02 of 2022 is not completed yet\n");
free(input);
size_t sz = 0;
char **input = get_lines("input/2022/02", &sz);
int p1 = 0, p2 = 0;
for (size_t i = 0; i < sz; ++i) {
size_t sp_sz = 0;
char **sp = split(input[i], &sp_sz, " ");
int o = sp[0][0] - 'A';
int y = sp[1][0] - 'X';
p1 += sc2202[o][y];
p2 += sc2202p2[o][y];
free(sp);
}
printf("%d\n", p1);
printf("%d\n", p2);
del_lines(input);
}