Skip to content

Commit 9d02840

Browse files
committed
[LIB] Remove math module
It just contained lcm and gcf functions, which are not really needed
1 parent 0608ecf commit 9d02840

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

aoc_2023/src/day_08.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::collections::HashMap;
22

33
use common::{Answer, Solution};
4-
use aoc_lib::math::lcm;
54

65
pub struct Day08;
76

@@ -29,7 +28,6 @@ impl Solution for Day08 {
2928
}
3029

3130
/// Get the cycle length for each starting position, this is the number of positions you need to get from `AAA` to `ZZZ`.
32-
/// Calculate the least common multiple of all cycle lengths to get the number of steps needed to get from `AAA` to `ZZZ` for all starting positions.
3331
fn part_b(&self, input: &str) -> Answer {
3432
let map = parse(input);
3533

@@ -56,7 +54,9 @@ impl Solution for Day08 {
5654
}
5755
}
5856

59-
cycles.into_iter().reduce(lcm).unwrap().into()
57+
// Note: This works because the cycle lengths are all prime numbers.
58+
// This was not described in the problem, but should be true for all inputs.
59+
cycles.into_iter().product::<i32>().into()
6060
}
6161
}
6262

aoc_lib/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[macro_use]
22
pub mod regex;
33
pub mod direction;
4-
pub mod math;
54
pub mod matrix;

aoc_lib/src/math.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)