optimization

This commit is contained in:
Rh4096 2024-12-10 14:05:39 +07:00
parent a0653a8223
commit 68e14d9ef6
2 changed files with 20 additions and 5 deletions

View file

@ -10,7 +10,7 @@ use crate::utils::{coord::Coord as Crd, Result};
type Coord = Crd<i8>; type Coord = Crd<i8>;
struct HikingMap { struct HikingMap {
pub starting_points: HashSet<Coord>, pub starting_points: Vec<Coord>,
pub mountain: HashMap<Coord, u8>, pub mountain: HashMap<Coord, u8>,
} }
@ -35,10 +35,10 @@ impl HikingMap {
}) })
}) })
.fold( .fold(
(HashSet::new(), HashMap::new()), (Vec::new(), HashMap::new()),
|(mut spos, mut map), (coord, heigh)| { |(mut spos, mut map), (coord, heigh)| {
if heigh == 0 { if heigh == 0 {
spos.insert(coord); spos.push(coord);
} }
map.insert(coord, heigh); map.insert(coord, heigh);

View file

@ -9,8 +9,23 @@ macro_rules! define_solution {
} }
define_solution!( define_solution!(
day_1, day_2, day_3, day_4, day_5, day_6, day_7, day_8, day_9, day_10, day_11, day_12, day_13, day_1, day_2, day_3, day_4, day_5, day_6, day_7, day_8, day_9,
day_14, day_15, day_16, day_17, day_18, day_19, day_20, day_21, day_22, day_23, day_24, day_25, day_10,
// day_11,
// day_12,
// day_13,
// day_14,
// day_15,
// day_16,
// day_17,
// day_18,
// day_19,
// day_20,
// day_21,
// day_22,
// day_23,
// day_24,
// day_25,
); );
pub trait AocSolution { pub trait AocSolution {