This commit is contained in:
Max Bradbury 2022-12-03 09:06:36 +00:00
parent 8dfa008aae
commit 0ce91d44c0
1 changed files with 4 additions and 3 deletions

View File

@ -107,11 +107,12 @@ pub fn part_2(input: &str) -> u64 {
for throw in throws {
let mut throw: Vec<&str> = throw.split_whitespace().take(2).collect();
let player = throw.pop().unwrap();
let outcome= Outcome::from_str(throw.pop().unwrap()).unwrap();
let opponent = Move::from_str(throw.pop().unwrap()).unwrap();
let player = match Outcome::from_str(player).unwrap() {
Outcome::Win => opponent.is_beaten_by(),
let player = match outcome {
Outcome::Win => opponent.is_beaten_by(),
Outcome::Draw => opponent.clone(),
Outcome::Lose => opponent.beats(),
};