File tree Expand file tree Collapse file tree 1 file changed +5
-25
lines changed
Expand file tree Collapse file tree 1 file changed +5
-25
lines changed Original file line number Diff line number Diff line change @@ -3,35 +3,15 @@ namespace AdventOfCode.Y2025.Day12;
33using System ;
44using System . Linq ;
55using System . Text . RegularExpressions ;
6- record Todo ( int w , int h , int [ ] counts ) ;
76
87[ ProblemName ( "Christmas Tree Farm" ) ]
98class Solution : Solver {
109
1110 public object PartOne ( string input ) {
12- // π π π This problem was a joke by Eric. The solution is specific to the input.
13-
14- var blocks = input . Split ( "\n \n " ) ;
15-
16- var areas = (
17- from block in blocks [ ..^ 1 ]
18- let area = block . Count ( ch => ch == '#' )
19- select area
20- ) . ToArray ( ) ;
21-
22- var todos = (
23- from line in blocks . Last ( ) . Split ( "\n " )
24- let nums = Regex . Matches ( line , @"\d+" ) . Select ( m => int . Parse ( m . Value ) ) . ToArray ( )
25- select new Todo ( nums [ 0 ] , nums [ 1 ] , nums [ 2 ..] )
26- ) . ToArray ( ) ;
27-
28- var res = 0 ;
29- foreach ( var todo in todos ) {
30- var areaNeeded = Enumerable . Zip ( todo . counts , areas ) . Sum ( p => p . First * p . Second ) ;
31- if ( areaNeeded <= todo . w * todo . h ) {
32- res ++ ;
33- }
34- }
35- return res ;
11+ // π π π This problem was a joke by Eric. The solution is input specific.
12+ return input . Split ( "\n \n " ) . Last ( )
13+ . Split ( "\n " )
14+ . Select ( line => Regex . Matches ( line , @"\d+" ) . Select ( m => int . Parse ( m . Value ) ) . ToArray ( ) )
15+ . Count ( nums => nums [ 0 ] * nums [ 1 ] >= 9 * nums [ 2 ..] . Sum ( ) ) ;
3616 }
3717}
You canβt perform that action at this time.
0 commit comments