Skip to content

Commit 3ba4c17

Browse files
committed
2025 09.1
1 parent 1c1f50a commit 3ba4c17

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

data

Submodule data updated from f88c66e to 1b20d9b

src/aoc/y2025/day09.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2025 Lexi Robinson
2+
//
3+
// Licensed under the EUPL, Version 1.2
4+
//
5+
// You may not use this work except in compliance with the Licence.
6+
// You should have received a copy of the Licence along with this work. If not, see:
7+
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
8+
// See the Licence for the specific language governing permissions and limitations under the Licence.
9+
10+
use itertools::Itertools;
11+
12+
use crate::{AoCError, BigCoord2D, Coordinate};
13+
14+
pub fn part_1(data: crate::DataIn) -> crate::AoCResult<String> {
15+
let coords: Vec<BigCoord2D> = data.map(|line| line.parse()).try_collect()?;
16+
17+
let ret = coords
18+
.into_iter()
19+
.array_combinations()
20+
.map(|[a, b]| {
21+
let min = a.get_min(&b);
22+
let max = a.get_max(&b);
23+
((1 + max.x - min.x) * (1 + max.y - min.y), a, b)
24+
})
25+
.map(|(dist, a, b)| {
26+
log::debug!("Square of area {dist} between {a} and {b}");
27+
dist
28+
})
29+
.sorted_unstable()
30+
.next_back()
31+
.ok_or(AoCError::new("Not enough coords??"))?;
32+
33+
Ok(ret.to_string())
34+
}
35+
36+
inventory::submit!(crate::AoCDay {
37+
year: "2025",
38+
day: "9",
39+
part_1: crate::AoCPart {
40+
main: part_1,
41+
example: part_1
42+
},
43+
part_2: None
44+
});

src/aoc/y2025/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ pub mod day05;
1414
pub mod day06;
1515
pub mod day07;
1616
pub mod day08;
17+
pub mod day09;

0 commit comments

Comments
 (0)