-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.cpp
31 lines (25 loc) · 842 Bytes
/
2.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
#include <fstream>
#include <iostream>
#include <string>
#include <unordered_map>
std::unordered_map<std::string, int> match_one{
{"A X", 3 + 1}, {"B X", 3 + 1}, {"C X", 3 + 1},
{"A Y", 6 + 2}, {"B Y", 3 + 2}, {"C Y", 0 + 2},
{"A Z", 0 + 3}, {"B Z", 6 + 3}, {"C Z", 3 + 3}};
std::unordered_map<std::string, int> match_two{
{"A X", 0 + 3}, {"B X", 0 + 1}, {"C X", 0 + 2},
{"A Y", 3 + 1}, {"B Y", 3 + 2}, {"C Y", 3 + 3},
{"A Z", 6 + 2}, {"B Z", 6 + 3}, {"C Z", 6 + 1}};
int main(int argc, char *argv[]) {
if (argc < 2) {
return 1;
}
std::ifstream file(argv[1]);
int score_one = 0, score_two = 0;
for (std::string line; std::getline(file, line);) {
score_one += match_one[line];
score_two += match_two[line];
}
std::cout << score_one << std::endl;
std::cout << score_two << std::endl;
}