2022-02
This commit is contained in:
parent
3fdfd035b1
commit
bb8dbf7b5c
@ -1,10 +1,40 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "lfinput.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) {
|
void advent2022day02(void) {
|
||||||
char *input = get_input("input/2022/02");
|
size_t sz = 0;
|
||||||
printf("Solution for Day 02 of 2022 is not completed yet\n");
|
char **input = get_lines("input/2022/02", &sz);
|
||||||
free(input);
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user