multiple: Use FxHashMap for s p e e d

This commit is contained in:
ktims committed 2024-12-12 14:07:22 -08:00
1 parent 447ff5c62c
commit 6022d2cc39
6 files changed
+26 -7

No files matched your search

+3 -3
View File
@@ -1,10 +1,10 @@
use aoc_runner_derive::aoc;
use itertools::Itertools;
use std::collections::HashMap;
use rustc_hash::FxHashMap;
use std::iter::repeat;
type IntType = u64;
type CacheType = HashMap<Stone, IntType>;
type CacheType = FxHashMap<Stone, IntType>;
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
struct Stone(IntType);
@@ -66,7 +66,7 @@ fn count_blinks(stone: &Stone, blink: usize, cache: &mut Vec<CacheType>) -> IntT
}
fn blink_stones(stones: Stones, blinks: usize) -> IntType {
let mut cache = Vec::from_iter(repeat(CacheType::new()).take(blinks));
let mut cache = Vec::from_iter(repeat(CacheType::default()).take(blinks));
stones
.0
.iter()