Skip to content

Commit

Permalink
Add AoC day one, part two - dry run 🎄
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Dec 5, 2024
1 parent 8c314ea commit 9e206fd
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 16 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,15 @@
56332 26207
45819 39519</value>
</data>
<data name="DayOneExampleLists" xml:space="preserve">
<data name="DayOnePartOneExampleLists" xml:space="preserve">
<value>3 4
4 3
2 5
1 3
3 9
3 3</value>
</data>
<data name="DayOnePartTwoExampleLists" xml:space="preserve">
<value>3 4
4 3
2 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public sealed partial class DayOne
public void PartOne_Example()
{
const int expectedResult = 11;
RunTest(expectedResult, Datasets.DayOneExampleLists, PartOneDryRun);
RunTest(expectedResult, Datasets.DayOnePartOneExampleLists, PartOneDryRun);
}

[Fact]
Expand Down
32 changes: 32 additions & 0 deletions samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartTwo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Hussy.Net.Playground.AdventOfCode.Y2024;

public sealed partial class DayOne
{
[Fact]
public void PartTwo_Example()
{
const int expectedResult = 31;
RunTest(expectedResult, Datasets.DayOnePartTwoExampleLists, PartTwoDryRun);
}

[Fact]
public void PartTwo_Actual()
{
const int expectedResult = 20_719_933;
RunTest(expectedResult, Datasets.DayOneLists, PartTwoDryRun);
}

private static int PartTwoDryRun(
IEnumerable<int> leftList,
IEnumerable<int> rightList)
{
var result = 0;
foreach (var left in leftList)
{
var countInRight = rightList.Count(right => right == left);
result += left * countInRight;
}

return result;
}
}

0 comments on commit 9e206fd

Please sign in to comment.