Skip to content

Commit 65f2f90

Browse files
committed
chore: move tick to Rotation
1 parent 0781f5e commit 65f2f90

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

aoclp_solutions/src/y2025/day_01.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ fn all_moves() -> impl Iterator<Item = i64> {
3434
let from = dial;
3535
dial = rotation.apply(dial);
3636

37-
let tick = rotation.direction.one_tick();
38-
successors(Some(from), move |int_dial| Some(tick.apply(*int_dial)))
37+
let step = rotation.step();
38+
successors(Some(from), move |int_dial| Some(step.apply(*int_dial)))
3939
.skip(1)
4040
.take(rotation.clicks as usize)
4141
}))
@@ -48,12 +48,6 @@ enum RotationDirection {
4848
Right = 1,
4949
}
5050

51-
impl RotationDirection {
52-
fn one_tick(self) -> Rotation {
53-
Rotation { direction: self, clicks: 1 }
54-
}
55-
}
56-
5751
impl FromStr for RotationDirection {
5852
type Err = aoclp::Error;
5953

@@ -77,6 +71,10 @@ impl Rotation {
7771
fn apply(&self, dial: i64) -> i64 {
7872
(dial + self.clicks * (self.direction as i64)).rem_euclid(100)
7973
}
74+
75+
fn step(&self) -> Self {
76+
Self { direction: self.direction, clicks: 1 }
77+
}
8078
}
8179

8280
impl FromStr for Rotation {

0 commit comments

Comments
 (0)