Skip to content

Commit 3417360

Browse files
committed
12
1 parent 7503822 commit 3417360

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

β€Ž2025/Day12/Solution.csβ€Ž

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,15 @@ namespace AdventOfCode.Y2025.Day12;
33
using System;
44
using System.Linq;
55
using System.Text.RegularExpressions;
6-
record Todo(int w, int h, int[] counts);
76

87
[ProblemName("Christmas Tree Farm")]
98
class 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
}

0 commit comments

Comments
Β (0)