From 1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Fri, 2 Dec 2022 20:54:14 +0300 Subject: 2022, day2: continue at home --- 2022/day2/part1/Cargo.toml | 9 +++++++++ 2022/day2/part1/src/main.rs | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 2022/day2/part1/Cargo.toml create mode 100644 2022/day2/part1/src/main.rs (limited to '2022/day2/part1') diff --git a/2022/day2/part1/Cargo.toml b/2022/day2/part1/Cargo.toml new file mode 100644 index 0000000..f14fe90 --- /dev/null +++ b/2022/day2/part1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "part1" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +itertools = "0.10.5" 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 @@ +let rps_result = vec![4, 1, 7, 8, 5, 2, 3, 9 ,6]; + + +fn main() { + let score = include_str!("../../example").lines().fold(0, parse_line); +} + +fn parse_line(score: usize, line: &str) -> usize { + let mut moves = line.split(' '); + let opponent_move = moves.next().unwrap(); + let my_move = moves.next().unwrap(); + + match opponent_move { + "A" => 1, + "B" => 2, + "C" => 3, + _ => unreachable!(), + }; + + 0 + score +} -- cgit v1.2.3-70-g09d2