aboutsummaryrefslogtreecommitdiff
path: root/2022/02/b.rs
blob: 9f2b580052bdca31d57d9b2353615cf9a5960afd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
mod common;
use common::*;

pub fn main() {
    let play_score = |s: &[u8]| {
        let other = s[0] as i64 - ('A' as i64);
        let w = s[2] as i64 - ('X' as i64);
        (other + w + 2) % 3 + 1
    };
    let win_score = |s: &[u8]| 3 * ((s[2] as i64) - ('X' as i64));
    let score = get_score(play_score, win_score);
    println!("{score}");
}

Generated with cgit - Back to sebastiano.tronto.net