From fa26f694d8cf98272763952a698301ee9935c19e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 26 Jun 2025 09:47:23 +0200 Subject: Added 2022, first few problems --- 2022/02/a.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 2022/02/a.rs (limited to '2022/02/a.rs') diff --git a/2022/02/a.rs b/2022/02/a.rs new file mode 100644 index 0000000..1a49a6b --- /dev/null +++ b/2022/02/a.rs @@ -0,0 +1,13 @@ +mod common; +use common::*; + +pub fn main() { + let play_score = |s: &[u8]| (s[2] as i64) - ('X' as i64) + 1; + let win_score = |s: &[u8]| { + let other = s[0] as i64 - ('A' as i64); + let me = s[2] as i64 - ('X' as i64); + 3 * ((me - other + 4) % 3) + }; + let score = get_score(play_score, win_score); + println!("{score}"); +} -- cgit v1.3