Skip to content

Commit c2ac784

Browse files
committed
chore: tidy
1 parent 04d9f50 commit c2ac784

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

aoclp_solutions/src/y2025/day_09.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use std::cmp::{max, min};
22
use std::collections::HashMap;
33
use std::iter::{once, successors};
4+
5+
use aoclp::positioning::direction::four_points::Direction4;
46
use aoclp::positioning::pt::{rectangular_area, Pt};
57
use aoclp::solvers_impl::input::safe_get_input_as_many;
68
use itertools::Itertools;
7-
use aoclp::positioning::direction::four_points::Direction4;
89

910
pub fn part_1() -> i64 {
1011
input()
@@ -28,14 +29,17 @@ pub fn part_2() -> i64 {
2829

2930
let safe = successors(Some(p), |&p| (p.y > safe_line).then_some(p + Direction4::Up))
3031
.filter(|p| path.get(p).is_some_and(|&step| step == PathStep::LeftRight))
31-
.count() % 2 != 0;
32+
.count()
33+
% 2
34+
!= 0;
3235
pt_safety.insert(p, safe);
3336
safe
3437
};
3538
let mut safe_line = |a: Pt, b: Pt| -> bool {
3639
let displacement = Pt::new((b.x - a.x).signum(), (b.y - a.y).signum());
37-
successors(Some(a), |&p| (p != b).then_some(p + displacement)).chain(Some(b))
38-
.all(|p| safe_pt(p))
40+
successors(Some(a), |&p| (p != b).then_some(p + displacement))
41+
.chain(Some(b))
42+
.all(&mut safe_pt)
3943
};
4044
let mut safe_rectangle = |a: Pt, b: Pt| {
4145
let corners = [
@@ -90,7 +94,8 @@ fn build_path(red_tiles: &[Pt]) -> HashMap<Pt, PathStep> {
9094
let displacement = Pt::new((b.x - a.x).signum(), (b.y - a.y).signum());
9195
successors(Some((a, PathStep::Corner)), move |&(p, _)| {
9296
(p != b).then_some((p + displacement, step))
93-
}).chain(once((b, PathStep::Corner)))
97+
})
98+
.chain(once((b, PathStep::Corner)))
9499
})
95100
.collect()
96101
}

0 commit comments

Comments
 (0)