diff --git a/crates/year2024/Cargo.toml b/crates/year2024/Cargo.toml index a33ac8e..ed27ec0 100644 --- a/crates/year2024/Cargo.toml +++ b/crates/year2024/Cargo.toml @@ -12,3 +12,4 @@ utils = { path = "../utils" } [features] unsafe = ["utils/unsafe"] +const_lut = [] diff --git a/crates/year2024/src/day21.rs b/crates/year2024/src/day21.rs index 0604d50..fcf5f89 100644 --- a/crates/year2024/src/day21.rs +++ b/crates/year2024/src/day21.rs @@ -23,7 +23,9 @@ enum DirectionalKeypad { Left = 1, Down = 2, Right = 3, } +#[cfg(feature = "const_lut")] static PART1_MATRIX: [[u64; 11]; 11] = num_matrix(2); +#[cfg(feature = "const_lut")] static PART2_MATRIX: [[u64; 11]; 11] = num_matrix(25); impl Day21 { @@ -37,12 +39,20 @@ impl Day21 { #[must_use] pub fn part1(&self) -> u64 { - self.complexity(&PART1_MATRIX) + #[cfg(feature = "const_lut")] + return self.complexity(&PART1_MATRIX); + + #[cfg(not(feature = "const_lut"))] + return self.complexity(&num_matrix(2)); } #[must_use] pub fn part2(&self) -> u64 { - self.complexity(&PART2_MATRIX) + #[cfg(feature = "const_lut")] + return self.complexity(&PART2_MATRIX); + + #[cfg(not(feature = "const_lut"))] + return self.complexity(&num_matrix(25)); } fn complexity(&self, matrix: &[[u64; 11]; 11]) -> u64 {