refactor: rename variable

This commit is contained in:
Lennard Brinkhaus 2023-12-07 19:38:10 +01:00
parent faad5beb77
commit 8499d4e34d

View File

@ -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<Vec<Card>> 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<Vec<Card>> 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<usize> {
.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