use std::io::BufRead;
-use rustc_hash::FxHashMap;
-
use crate::utils;
-type Stones = FxHashMap<u64, u64>;
+type Stones = rustc_hash::FxHashMap<u64, u64>;
pub fn read(reader: &mut dyn BufRead) -> Stones {
Stones::from_iter(
)
}
-fn add_or_set(map: &mut FxHashMap<u64, u64>, 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<u64, u64>, i: u32) -> FxHashMap<u64, u64> {
+pub fn blink(stones: Stones, i: u32) -> Stones {
if i == 0 {
stones
} else {
- let mut next_stones = FxHashMap::<u64, u64>::default();
+ let mut next_stones = Stones::default();
for (stone, n) in stones {
if stone == 0 {
add_or_set(&mut next_stones, 1, n);