From 644437a90e8b3839684a0f85b01b7096864b9b3b Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Wed, 11 Dec 2024 18:25:51 +0100 Subject: [PATCH] Use Stones alias --- src/day11.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/day11.rs b/src/day11.rs index c9c39d7..be2f8f8 100644 --- a/src/day11.rs +++ b/src/day11.rs @@ -1,10 +1,8 @@ use std::io::BufRead; -use rustc_hash::FxHashMap; - use crate::utils; -type Stones = FxHashMap; +type Stones = rustc_hash::FxHashMap; pub fn read(reader: &mut dyn BufRead) -> Stones { Stones::from_iter( @@ -14,15 +12,15 @@ pub fn read(reader: &mut dyn BufRead) -> Stones { ) } -fn add_or_set(map: &mut FxHashMap, k: u64, n: u64) { +fn add_or_set(map: &mut Stones, k: u64, n: u64) { map.entry(k).and_modify(|v| *v += n).or_insert(n); } -pub fn blink(stones: FxHashMap, i: u32) -> FxHashMap { +pub fn blink(stones: Stones, i: u32) -> Stones { if i == 0 { stones } else { - let mut next_stones = FxHashMap::::default(); + let mut next_stones = Stones::default(); for (stone, n) in stones { if stone == 0 { add_or_set(&mut next_stones, 1, n); -- 2.45.2