From 9e206fda3c22ba9d8c6eb009ae97b49eeae9dcb7 Mon Sep 17 00:00:00 2001 From: tacosontitan Date: Wed, 4 Dec 2024 22:04:10 -0600 Subject: [PATCH] =?UTF-8?q?Add=20AoC=20day=20one,=20part=20two=20-=20dry?= =?UTF-8?q?=20run=20=F0=9F=8E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdventOfCode/Y2024/Datasets.Designer.cs | 42 ++++++++++++------- .../AdventOfCode/Y2024/Datasets.resx | 10 ++++- .../AdventOfCode/Y2024/Day1/PartOne.cs | 2 +- .../AdventOfCode/Y2024/Day1/PartTwo.cs | 32 ++++++++++++++ 4 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartTwo.cs diff --git a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.Designer.cs b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.Designer.cs index bec6868..1c6a094 100644 --- a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.Designer.cs +++ b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.Designer.cs @@ -59,20 +59,6 @@ internal Datasets() { } } - /// - /// Looks up a localized string similar to 3 4 - ///4 3 - ///2 5 - ///1 3 - ///3 9 - ///3 3. - /// - internal static string DayOneExampleLists { - get { - return ResourceManager.GetString("DayOneExampleLists", resourceCulture); - } - } - /// /// Looks up a localized string similar to 35039 67568 ///61770 80134 @@ -115,5 +101,33 @@ internal static string DayOneLists { return ResourceManager.GetString("DayOneLists", resourceCulture); } } + + /// + /// Looks up a localized string similar to 3 4 + ///4 3 + ///2 5 + ///1 3 + ///3 9 + ///3 3. + /// + internal static string DayOnePartOneExampleLists { + get { + return ResourceManager.GetString("DayOnePartOneExampleLists", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 3 4 + ///4 3 + ///2 5 + ///1 3 + ///3 9 + ///3 3. + /// + internal static string DayOnePartTwoExampleLists { + get { + return ResourceManager.GetString("DayOnePartTwoExampleLists", resourceCulture); + } + } } } diff --git a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.resx b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.resx index 13ce2af..3c5e679 100644 --- a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.resx +++ b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Datasets.resx @@ -1020,7 +1020,15 @@ 56332 26207 45819 39519 - + + 3 4 +4 3 +2 5 +1 3 +3 9 +3 3 + + 3 4 4 3 2 5 diff --git a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartOne.cs b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartOne.cs index bb04b1f..f14a02c 100644 --- a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartOne.cs +++ b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartOne.cs @@ -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] diff --git a/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartTwo.cs b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartTwo.cs new file mode 100644 index 0000000..e46361f --- /dev/null +++ b/samples/Hussy.Net.Playground/AdventOfCode/Y2024/Day1/PartTwo.cs @@ -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 leftList, + IEnumerable rightList) + { + var result = 0; + foreach (var left in leftList) + { + var countInRight = rightList.Count(right => right == left); + result += left * countInRight; + } + + return result; + } +} \ No newline at end of file