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 input = ParsePuzzleInput(pathToPuzzleInput);
|
||||||
var result = input
|
var result = input
|
||||||
.GroupBy(id => id)
|
.CountBy(id => id)
|
||||||
.OrderByDescending(g => g.Count())
|
.OrderByDescending(g => g.Value)
|
||||||
.Take(3)
|
.Take(3)
|
||||||
.Aggregate(1L, (agg, next) => agg * next.Key);
|
.Aggregate(1L, (agg, next) => agg * next.Key);
|
||||||
return result;
|
return result;
|
||||||
@@ -28,8 +28,8 @@ public class Day01 : IPuzzleSolver<long>
|
|||||||
{
|
{
|
||||||
var input = ParsePuzzleInput(pathToPuzzleInput);
|
var input = ParsePuzzleInput(pathToPuzzleInput);
|
||||||
var result = input
|
var result = input
|
||||||
.GroupBy(id => id)
|
.CountBy(id => id)
|
||||||
.OrderBy(g => g.Count())
|
.OrderBy(g => g.Value)
|
||||||
.Take(3)
|
.Take(3)
|
||||||
.Aggregate(1L, (agg, next) => agg * next.Key);
|
.Aggregate(1L, (agg, next) => agg * next.Key);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in new issue
Block a user