Skip to content

Commit 7c0fd24

Browse files
committed
2024/14
1 parent da20669 commit 7c0fd24

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

2024/Day14/Solution.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ class Solution : Solver {
1414
const int height = 103;
1515

1616
// run the simulation for 100 steps and count the robots in the different quadrants.
17-
public object PartOne(string input) {
18-
var quadrants = Simulate(input)
19-
.ElementAt(100)
20-
.CountBy(GetQuadrant)
21-
.Where(group => group.Key.x != 0 && group.Key.y != 0)
22-
.Select(group => group.Value)
23-
.ToArray();
24-
return quadrants[0] * quadrants[1] * quadrants[2] * quadrants[3];
25-
}
17+
public object PartOne(string input) =>
18+
Simulate(input)
19+
.ElementAt(100)
20+
.CountBy(GetQuadrant)
21+
.Where(group => group.Key.x != 0 && group.Key.y != 0)
22+
.Aggregate(1, (acc, group) => acc * group.Value);
2623

27-
// i figured that the xmas tree pattern has a long horizontal ### pattern in it
24+
// I figured that the xmas tree pattern has a long horizontal ### pattern in it
2825
public object PartTwo(string input) =>
2926
Simulate(input)
3027
.TakeWhile(robots => !Plot(robots).Contains("#################"))

0 commit comments

Comments
 (0)