From a8ae57bc8c6270862a8784f5e163c21cd5e2dde0 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Mon, 4 Dec 2023 23:18:11 -0600
Subject: [PATCH 1/7] chore: scaffold for day 5 puzzle
---
05/IYGASAF.Tests/GlobalUsings.cs | 2 ++
05/IYGASAF.Tests/IYGASAF.Tests.csproj | 36 +++++++++++++++++++++++++++
05/IYGASAF.Tests/UnitTest1.cs | 10 ++++++++
05/IYGASAF/IYGASAF.csproj | 10 ++++++++
05/IYGASAF/Program.cs | 2 ++
AdventOfCode2023.sln | 16 ++++++++++++
6 files changed, 76 insertions(+)
create mode 100644 05/IYGASAF.Tests/GlobalUsings.cs
create mode 100644 05/IYGASAF.Tests/IYGASAF.Tests.csproj
create mode 100644 05/IYGASAF.Tests/UnitTest1.cs
create mode 100644 05/IYGASAF/IYGASAF.csproj
create mode 100644 05/IYGASAF/Program.cs
diff --git a/05/IYGASAF.Tests/GlobalUsings.cs b/05/IYGASAF.Tests/GlobalUsings.cs
new file mode 100644
index 0000000..7fef4b0
--- /dev/null
+++ b/05/IYGASAF.Tests/GlobalUsings.cs
@@ -0,0 +1,2 @@
+global using Xunit;
+global using FluentAssertions;
\ No newline at end of file
diff --git a/05/IYGASAF.Tests/IYGASAF.Tests.csproj b/05/IYGASAF.Tests/IYGASAF.Tests.csproj
new file mode 100644
index 0000000..c1844dc
--- /dev/null
+++ b/05/IYGASAF.Tests/IYGASAF.Tests.csproj
@@ -0,0 +1,36 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
diff --git a/05/IYGASAF.Tests/UnitTest1.cs b/05/IYGASAF.Tests/UnitTest1.cs
new file mode 100644
index 0000000..6c2a1c6
--- /dev/null
+++ b/05/IYGASAF.Tests/UnitTest1.cs
@@ -0,0 +1,10 @@
+namespace IYGASAF.Tests;
+
+public class UnitTest1
+{
+ [Fact]
+ public void Test1()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/05/IYGASAF/IYGASAF.csproj b/05/IYGASAF/IYGASAF.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/05/IYGASAF/IYGASAF.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/05/IYGASAF/Program.cs b/05/IYGASAF/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/05/IYGASAF/Program.cs
@@ -0,0 +1,2 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
diff --git a/AdventOfCode2023.sln b/AdventOfCode2023.sln
index 3e793ae..2c0a187 100644
--- a/AdventOfCode2023.sln
+++ b/AdventOfCode2023.sln
@@ -27,6 +27,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scratchcards", "04\Scratchc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scratchcards.Tests", "04\Scratchcards.Tests\Scratchcards.Tests.csproj", "{FF8A5512-85FD-45E7-9F97-EC528465949C}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05", "05", "{5067FD6B-8F03-4502-AB83-8A391D801B47}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IYGASAF", "05\IYGASAF\IYGASAF.csproj", "{417E0408-31C8-4945-B684-5004233D6AF4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IYGASAF.Tests", "05\IYGASAF.Tests\IYGASAF.Tests.csproj", "{CB90004D-9420-4411-9110-B50274537FE5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +74,14 @@ Global
{FF8A5512-85FD-45E7-9F97-EC528465949C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF8A5512-85FD-45E7-9F97-EC528465949C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF8A5512-85FD-45E7-9F97-EC528465949C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {417E0408-31C8-4945-B684-5004233D6AF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {417E0408-31C8-4945-B684-5004233D6AF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {417E0408-31C8-4945-B684-5004233D6AF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {417E0408-31C8-4945-B684-5004233D6AF4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CB90004D-9420-4411-9110-B50274537FE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CB90004D-9420-4411-9110-B50274537FE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CB90004D-9420-4411-9110-B50274537FE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CB90004D-9420-4411-9110-B50274537FE5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F8EAC09-4BC7-43AA-B72B-48DDD2710F6D} = {8C29858C-623A-461A-BF0B-254E151CD9C2}
@@ -78,5 +92,7 @@ Global
{FEE9253C-A56B-4735-BDB3-C62220C5B1B1} = {EA04152D-316A-4AA4-9BC1-57F6A9F3CD4E}
{B58CF14B-97A1-45F6-967F-29FA82DAFD0F} = {522D6D1E-54AD-4479-BB78-0AB5D7493EFC}
{FF8A5512-85FD-45E7-9F97-EC528465949C} = {522D6D1E-54AD-4479-BB78-0AB5D7493EFC}
+ {417E0408-31C8-4945-B684-5004233D6AF4} = {5067FD6B-8F03-4502-AB83-8A391D801B47}
+ {CB90004D-9420-4411-9110-B50274537FE5} = {5067FD6B-8F03-4502-AB83-8A391D801B47}
EndGlobalSection
EndGlobal
From d70d1c8bce16f3a75dce2f3594a1695a91830341 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Tue, 5 Dec 2023 16:17:38 -0600
Subject: [PATCH 2/7] chore: stub out program.cs
---
05/IYGASAF/Program.cs | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/05/IYGASAF/Program.cs b/05/IYGASAF/Program.cs
index 3751555..ebf228a 100644
--- a/05/IYGASAF/Program.cs
+++ b/05/IYGASAF/Program.cs
@@ -1,2 +1,9 @@
-// See https://aka.ms/new-console-template for more information
-Console.WriteLine("Hello, World!");
+namespace IYGASAF;
+
+public class Program
+{
+ public static async Task Main(string[] args)
+ {
+ return await Task.FromResult(0);
+ }
+}
\ No newline at end of file
From e4ff5ed4c44baebd50c63acbb43cb270c4e8fb43 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Tue, 5 Dec 2023 19:52:23 -0600
Subject: [PATCH 3/7] feat: solve part 1 of puzzle 5
---
05/IYGASAF.Tests/AlmanacTests.cs | 140 ++++++++++++++++
05/IYGASAF.Tests/MapTests.cs | 275 +++++++++++++++++++++++++++++++
05/IYGASAF.Tests/RangeTests.cs | 23 +++
05/IYGASAF.Tests/UnitTest1.cs | 10 --
05/IYGASAF/Program.cs | 154 ++++++++++++++++-
5 files changed, 591 insertions(+), 11 deletions(-)
create mode 100644 05/IYGASAF.Tests/AlmanacTests.cs
create mode 100644 05/IYGASAF.Tests/MapTests.cs
create mode 100644 05/IYGASAF.Tests/RangeTests.cs
delete mode 100644 05/IYGASAF.Tests/UnitTest1.cs
diff --git a/05/IYGASAF.Tests/AlmanacTests.cs b/05/IYGASAF.Tests/AlmanacTests.cs
new file mode 100644
index 0000000..9d6b07c
--- /dev/null
+++ b/05/IYGASAF.Tests/AlmanacTests.cs
@@ -0,0 +1,140 @@
+namespace IYGASAF.Tests;
+
+public class AlmanacTests
+{
+ private readonly Almanac _sut = TestData.TestAlmanac;
+
+ [Theory]
+ [MemberData(nameof(TestData.TestAlmanacData), MemberType = typeof(TestData))]
+ public void Parse_WhenGivenValidAlmanac_ItShouldReturnExpectedAlmanac(string[] almanac, Almanac expected)
+ {
+ var result = Almanac.Parse(almanac);
+ result.Should().BeEquivalentTo(expected);
+ }
+
+ [Theory]
+ [InlineData(79, 82)]
+ [InlineData(14, 43)]
+ [InlineData(55, 86)]
+ [InlineData(13, 35)]
+ public void GetSeedLocation_WhenGivenValidSeed_ItShouldReturnExpectedLocation(int seed, int expected)
+ {
+ var result = _sut.GetSeedLocation(seed);
+ result.Should().Be(expected);
+ }
+
+ [Fact]
+ public void GetLowestSeedLocation_WhenCalled_ItShouldReturnExpectedLocation()
+ {
+ var result = _sut.GetLowestSeedLocation();
+ result.Should().Be(35);
+ }
+
+ [Fact]
+ public void GetLowestSeedLocation_WhenCalledWithPuzzleInput_ItShouldReturnExpectedLocation()
+ {
+ var almanac = File.ReadAllLines("INPUT.txt");
+ var sut = Almanac.Parse(almanac);
+ var result = sut.GetLowestSeedLocation();
+ result.Should().Be(806029445);
+ }
+
+ public static class TestData
+ {
+ public static readonly Almanac TestAlmanac =
+ new(
+ [
+ 79,
+ 14,
+ 55,
+ 13,
+ ],
+ [
+ new(
+ [
+ new(2, 98, 50),
+ new(48, 50, 52),
+ ]
+ ),
+ new(
+ [
+ new(37, 15, 0),
+ new(2, 52, 37),
+ new(15, 0, 39),
+ ]
+ ),
+ new(
+ [
+ new(8, 53, 49),
+ new(42, 11, 0),
+ new(7, 0, 42),
+ new(4, 7, 57),
+ ]
+ ),
+ new(
+ [
+ new(7, 18, 88),
+ new(70, 25, 18),
+ ]
+ ),
+ new(
+ [
+ new(23, 77, 45),
+ new(19, 45, 81),
+ new(13, 64, 68),
+ ]
+ ),
+ new(
+ [
+ new(1, 69, 0),
+ new(69, 0, 1),
+ ]
+ ),
+ new(
+ [
+ new(37, 56, 60),
+ new(4, 93, 56),
+ ]
+ ),
+ ]
+ );
+
+ public static readonly IEnumerable