Skip to content

Commit 24b32c7

Browse files
committed
chore: y2025::day_09::part_1
1 parent 3eb8a61 commit 24b32c7

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

aoclp/src/positioning/pt.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ where
177177
(a.x - b.x).abs() + (a.y - b.y).abs()
178178
}
179179

180+
/// Returns the size of the rectangle formed between two points in 2D space,
181+
/// as if the points were the rectangle's top-left and bottom-right corners.
182+
pub fn rectangular_area<T>(a: Pt<T>, b: Pt<T>) -> T
183+
where
184+
T: Signed,
185+
{
186+
((a.x - b.x).abs() + T::one()) * ((a.y - b.y).abs() + T::one())
187+
}
188+
180189
/// Given a two-dimensional matrix of elements, returns a map of
181190
/// [`Pt`] associated with the element at that position in the matrix.
182191
pub fn matrix_to_map<T, M, R, PT>(matrix: M) -> HashMap<Pt<PT>, T>

aoclp_solutions/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ pub mod y2025;
1111
build_solvers! {
1212
{ 2017, [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] },
1313
{ 2024, [01, 02, 03, 04, 05, 06, 07, 08, 09, 10] },
14-
{ 2025, [01, 02, 03, 04, 05, 06, 07, 08] }
14+
{ 2025, [01, 02, 03, 04, 05, 06, 07, 08, 09] }
1515
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use aoclp::positioning::pt::{rectangular_area, Pt};
2+
use aoclp::solvers_impl::input::safe_get_input_as_many;
3+
use itertools::Itertools;
4+
5+
pub fn part_1() -> i64 {
6+
input()
7+
.into_iter()
8+
.array_combinations()
9+
.map(|[a, b]| rectangular_area(a, b))
10+
.max()
11+
.unwrap()
12+
}
13+
14+
pub fn part_2() -> usize {
15+
0
16+
}
17+
18+
fn input() -> Vec<Pt> {
19+
safe_get_input_as_many(2025, 9)
20+
}

aoclp_solutions/src/y2025/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pub mod day_05;
66
pub mod day_06;
77
pub mod day_07;
88
pub mod day_08;
9+
pub mod day_09;

0 commit comments

Comments
 (0)