27 lines
497 B
C
27 lines
497 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "../../lib/aoc.h"
|
|
|
|
int round_score(const char *round) {
|
|
int shape = round[2] - 'X' + 1;
|
|
int opponent_shape = round[0] - 'A' + 1;
|
|
int result = (((shape - opponent_shape) + 4) % 3) * 3;
|
|
return shape + result;
|
|
}
|
|
|
|
int main() {
|
|
int total_score = 0;
|
|
|
|
char *round;
|
|
while ((round = aoc_read_line()) != NULL) {
|
|
total_score += round_score(round);
|
|
}
|
|
|
|
printf("Part 1: %d\n", total_score);
|
|
|
|
aoc_free();
|
|
return 0;
|
|
}
|