diff --git a/src/day07.rs b/src/day07.rs index 69a1551..e7fdc5c 100644 --- a/src/day07.rs +++ b/src/day07.rs @@ -1,8 +1,5 @@ -use std::cmp::Ordering; use std::collections::HashMap; use std::fmt::{Display, Formatter}; -use std::panic::panic_any; -use std::sync::mpsc::TrySendError::Full; use std::time::Instant; use itertools::Itertools; @@ -21,7 +18,7 @@ pub enum Card { N4 = 12, N3 = 13, N2 = 14, - JOKER_2 = 15, + Joker = 15, } @@ -72,7 +69,7 @@ impl From> for Hand { } let key = cards.keys() - .filter(|k| k.to_string() != "JOKER_2") + .filter(|k| k.to_string() != "Joker") .map(|k| (k, cards[k])) .max_by(|(_, v1), (_, v2)| Ord::cmp(v1, v2)); @@ -81,9 +78,9 @@ impl From> for Hand { } let key = key.unwrap().0.to_owned(); - let joker = cards.get("JOKER_2").unwrap_or(&0).clone(); + let joker = cards.get("Joker").unwrap_or(&0).clone(); *cards.entry(key).or_default() += joker; - cards.remove("JOKER_2"); + cards.remove("Joker"); match cards.values().len() { @@ -147,7 +144,7 @@ fn solve_02(content: &str) -> anyhow::Result { .map(|(hand, bid)| (hand.chars().map(|c| { let mut c = Card::from(c); if c == Card::J { - c = Card::JOKER_2; + c = Card::Joker; } c