File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ pub mod day05;
1414pub mod day06;
1515pub mod day07;
1616pub mod day08;
17+ pub mod day09;
You can’t perform that action at this time.
0 commit comments