diff options
Diffstat (limited to '2022/day2/part1/src/main.rs')
-rw-r--r-- | 2022/day2/part1/src/main.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/2022/day2/part1/src/main.rs b/2022/day2/part1/src/main.rs new file mode 100644 index 0000000..44ebe3a --- /dev/null +++ b/2022/day2/part1/src/main.rs | |||
@@ -0,0 +1,21 @@ | |||
1 | let rps_result = vec![4, 1, 7, 8, 5, 2, 3, 9 ,6]; | ||
2 | |||
3 | |||
4 | fn main() { | ||
5 | let score = include_str!("../../example").lines().fold(0, parse_line); | ||
6 | } | ||
7 | |||
8 | fn parse_line(score: usize, line: &str) -> usize { | ||
9 | let mut moves = line.split(' '); | ||
10 | let opponent_move = moves.next().unwrap(); | ||
11 | let my_move = moves.next().unwrap(); | ||
12 | |||
13 | match opponent_move { | ||
14 | "A" => 1, | ||
15 | "B" => 2, | ||
16 | "C" => 3, | ||
17 | _ => unreachable!(), | ||
18 | }; | ||
19 | |||
20 | 0 + score | ||
21 | } | ||