diff options
author | Yigit Sever | 2022-12-02 20:54:14 +0300 |
---|---|---|
committer | Yigit Sever | 2022-12-02 20:54:14 +0300 |
commit | 1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358 (patch) | |
tree | 16309d21cfa4461acbe599018a42644b65c4ac14 /2022/day2/part1/src/main.rs | |
parent | dcb1c08422a46f1f43d7002a3d4790b713dd9eab (diff) | |
download | aoc-1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358.tar.gz aoc-1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358.tar.bz2 aoc-1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358.zip |
2022, day2: continue at home
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 | } | ||