Refactor Day01 to use CountBy for ID counting
This commit is contained in:
1 parent
2f05acf3ca
commit
dd9209f2d0
1 file changed
+4
-4
+4
-4
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user