From: Greg Burri Date: Wed, 11 Dec 2024 17:25:51 +0000 (+0100) Subject: Use Stones alias X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=644437a90e8b3839684a0f85b01b7096864b9b3b;p=advent_of_code_2024.git Use Stones alias --- 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);