File tree Expand file tree Collapse file tree 3 files changed +3
-19
lines changed Expand file tree Collapse file tree 3 files changed +3
-19
lines changed Original file line number Diff line number Diff line change 1
1
use std:: collections:: HashMap ;
2
2
3
3
use common:: { Answer , Solution } ;
4
- use aoc_lib:: math:: lcm;
5
4
6
5
pub struct Day08 ;
7
6
@@ -29,7 +28,6 @@ impl Solution for Day08 {
29
28
}
30
29
31
30
/// 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.
33
31
fn part_b ( & self , input : & str ) -> Answer {
34
32
let map = parse ( input) ;
35
33
@@ -56,7 +54,9 @@ impl Solution for Day08 {
56
54
}
57
55
}
58
56
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 ( )
60
60
}
61
61
}
62
62
Original file line number Diff line number Diff line change 1
1
#[ macro_use]
2
2
pub mod regex;
3
3
pub mod direction;
4
- pub mod math;
5
4
pub mod matrix;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments