-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.cpp
63 lines (57 loc) · 1.67 KB
/
day2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by Johannes Loepelmann on 02.12.22.
//
#include "util.h"
int main() {
const auto lines = read_strings_from_file("day2.input");
int sum = 0;
for(const auto& line : lines) {
char opp = line.at(0);
char me = line.at(2);
if(opp == 'A' && me == 'X') {
sum += 4;
} else if(opp == 'A' && me == 'Y') {
sum += 8;
} else if(opp == 'A' && me == 'Z') {
sum += 3;
} else if(opp == 'B' && me == 'X') {
sum += 1;
} else if(opp == 'B' && me == 'Y') {
sum += 5;
} else if(opp == 'B' && me == 'Z') {
sum += 9;
} else if(opp == 'C' && me == 'X') {
sum += 7;
} else if(opp == 'C' && me == 'Y') {
sum += 2;
} else if(opp == 'C' && me == 'Z') {
sum += 6;
}
}
std::cout << "Sum 1: " << sum << std::endl;
sum = 0;
for(const auto& line : lines) {
char opp = line.at(0);
char res = line.at(2);
if(opp == 'A' && res == 'X') {
sum += 3;
} else if(opp == 'A' && res == 'Y') {
sum += 4;
} else if(opp == 'A' && res == 'Z') {
sum += 8;
} else if(opp == 'B' && res == 'X') {
sum += 1;
} else if(opp == 'B' && res == 'Y') {
sum += 5;
} else if(opp == 'B' && res == 'Z') {
sum += 9;
} else if(opp == 'C' && res == 'X') {
sum += 2;
} else if(opp == 'C' && res == 'Y') {
sum += 6;
} else if(opp == 'C' && res == 'Z') {
sum += 7;
}
}
std::cout << "Sum 2: " << sum << std::endl;
}