blob: 51522920d7a90ffe077aa519cd9e67cf174bf2b5 (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#include<bits/stdc++.h>
#include <cstdio>
#include <sstream>
using namespace std;
void solvePart1() {
char n, m;
int ans = 0;
int rockPoints = 1, paperPoints = 2, scissorsPoints = 3;
int win = 6, draw = 3, loss = 0;
// y = B = paper
// x = A = rock
// z = C = scissors
while(cin >> n >> m) {
if (n == 'A') {
switch(m) {
case 'Y': {
ans += paperPoints + win;
break;
}
case 'X': {
ans += rockPoints + draw;
break;
}
case 'Z': {
ans += scissorsPoints + loss;
break;
}
}
} else if (n == 'B') {
switch(m) {
case 'Y': {
ans += paperPoints + draw;
break;
}
case 'X': {
ans += rockPoints + loss;
break;
}
case 'Z': {
ans += scissorsPoints + win;
break;
}
}
} else if (n == 'C') {
switch(m) {
case 'Y': {
ans += paperPoints + loss;
break;
}
case 'X': {
ans += rockPoints + win;
break;
}
case 'Z': {
ans += scissorsPoints + draw;
break;
}
}
}
}
cout << "Part1: " << ans << '\n';
}
void solvePart2() {
char n, m;
int ans = 0;
int rockPoints = 1, paperPoints = 2, scissorsPoints = 3;
int win = 6, draw = 3, loss = 0;
while(cin >> n >> m) {
if (n == 'A') {
switch(m) {
case 'Y': {
ans += rockPoints + draw;
break;
}
case 'X': {
ans += scissorsPoints + loss;
break;
}
case 'Z': {
ans += paperPoints + win;
break;
}
}
} else if (n == 'B') {
switch(m) {
case 'Y': {
ans += paperPoints + draw;
break;
}
case 'X': {
ans += rockPoints + loss;
break;
}
case 'Z': {
ans += scissorsPoints + win;
break;
}
}
} else if (n == 'C') {
switch(m) {
case 'Y': {
ans += scissorsPoints + draw;
break;
}
case 'X': {
ans += paperPoints + loss;
break;
}
case 'Z': {
ans += rockPoints + win;
break;
}
}
}
}
cout << "Part2: " << ans << '\n';
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solvePart1();
// solvePart2();
}
|