aboutsummaryrefslogtreecommitdiff
path: root/2022/02/b.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/02/b.rs')
-rw-r--r--2022/02/b.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/2022/02/b.rs b/2022/02/b.rs
new file mode 100644
index 0000000..9f2b580
--- /dev/null
+++ b/2022/02/b.rs
@@ -0,0 +1,13 @@
1mod common;
2use common::*;
3
4pub fn main() {
5 let play_score = |s: &[u8]| {
6 let other = s[0] as i64 - ('A' as i64);
7 let w = s[2] as i64 - ('X' as i64);
8 (other + w + 2) % 3 + 1
9 };
10 let win_score = |s: &[u8]| 3 * ((s[2] as i64) - ('X' as i64));
11 let score = get_score(play_score, win_score);
12 println!("{score}");
13}

Generated with cgit - Back to sebastiano.tronto.net