Function aoc::y22d02::y22d02

source ·
pub fn y22d02(input: &str, part: u32) -> u32
Expand description

The solution for the day two challenge.

Given the input as a string, it splits by lines and then creates a running tally as it loops through them as each possible outcome is stored in a std::collections::HashMap with its value.

The second argument simply decides whether we should use the what to play method (part 1) or the what to do method (part 2).

§Example

let input = "A X\nB X"; // probably read this from the input file...
assert_eq!(y22d02(input, 1), 5);
assert_eq!(y22d02(input, 2), 4);