Refactor Day01 to use CountBy for ID counting

This commit is contained in:
Sebastian Lindemeier committed 2026-12-01 09:53:47 +01:00
1 parent 2f05acf3ca
commit dd9209f2d0
1 file changed
+4 -4
+4 -4
View File
@@ -17,8 +17,8 @@ public class Day01 : IPuzzleSolver<long>
{
var input = ParsePuzzleInput(pathToPuzzleInput);
var result = input
.GroupBy(id => id)
.OrderByDescending(g => g.Count())
.CountBy(id => id)
.OrderByDescending(g => g.Value)
.Take(3)
.Aggregate(1L, (agg, next) => agg * next.Key);
return result;
@@ -28,8 +28,8 @@ public class Day01 : IPuzzleSolver<long>
{
var input = ParsePuzzleInput(pathToPuzzleInput);
var result = input
.GroupBy(id => id)
.OrderBy(g => g.Count())
.CountBy(id => id)
.OrderBy(g => g.Value)
.Take(3)
.Aggregate(1L, (agg, next) => agg * next.Key);
return result;