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

Lines changed: 7 additions & 10 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy