From 8822e2f94471710223a6c66570f9952956f33f85 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Sat, 9 Dec 2023 23:39:38 -0600
Subject: [PATCH 1/5] chore: scaffold for day 10 puzzle
---
10/PipeMaze.Tests/GlobalUsings.cs | 2 ++
10/PipeMaze.Tests/PipeMaze.Tests.csproj | 30 +++++++++++++++++++++++++
10/PipeMaze.Tests/UnitTest1.cs | 10 +++++++++
10/PipeMaze/PipeMaze.csproj | 10 +++++++++
10/PipeMaze/Program.cs | 2 ++
AdventOfCode2023.sln | 16 +++++++++++++
6 files changed, 70 insertions(+)
create mode 100644 10/PipeMaze.Tests/GlobalUsings.cs
create mode 100644 10/PipeMaze.Tests/PipeMaze.Tests.csproj
create mode 100644 10/PipeMaze.Tests/UnitTest1.cs
create mode 100644 10/PipeMaze/PipeMaze.csproj
create mode 100644 10/PipeMaze/Program.cs
diff --git a/10/PipeMaze.Tests/GlobalUsings.cs b/10/PipeMaze.Tests/GlobalUsings.cs
new file mode 100644
index 0000000..7fef4b0
--- /dev/null
+++ b/10/PipeMaze.Tests/GlobalUsings.cs
@@ -0,0 +1,2 @@
+global using Xunit;
+global using FluentAssertions;
\ No newline at end of file
diff --git a/10/PipeMaze.Tests/PipeMaze.Tests.csproj b/10/PipeMaze.Tests/PipeMaze.Tests.csproj
new file mode 100644
index 0000000..ee3cd62
--- /dev/null
+++ b/10/PipeMaze.Tests/PipeMaze.Tests.csproj
@@ -0,0 +1,30 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/10/PipeMaze.Tests/UnitTest1.cs b/10/PipeMaze.Tests/UnitTest1.cs
new file mode 100644
index 0000000..2ae55c5
--- /dev/null
+++ b/10/PipeMaze.Tests/UnitTest1.cs
@@ -0,0 +1,10 @@
+namespace PipeMaze.Tests;
+
+public class UnitTest1
+{
+ [Fact]
+ public void Test1()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/10/PipeMaze/PipeMaze.csproj b/10/PipeMaze/PipeMaze.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/10/PipeMaze/PipeMaze.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/10/PipeMaze/Program.cs b/10/PipeMaze/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/10/PipeMaze/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 f963b6c..6ea177f 100644
--- a/AdventOfCode2023.sln
+++ b/AdventOfCode2023.sln
@@ -57,6 +57,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MirageMaintenance", "09\Mir
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MirageMaintenance.Tests", "09\MirageMaintenance.Tests\MirageMaintenance.Tests.csproj", "{5C39C115-ACBF-458A-9409-FBD23637A789}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "10", "10", "{9703A36A-A019-4ADC-93A7-9DF4EFBCBFBC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PipeMaze", "10\PipeMaze\PipeMaze.csproj", "{B46ADCFF-35FF-496D-A035-FE2B9FFC185A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PipeMaze.Tests", "10\PipeMaze.Tests\PipeMaze.Tests.csproj", "{B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -138,6 +144,14 @@ Global
{5C39C115-ACBF-458A-9409-FBD23637A789}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C39C115-ACBF-458A-9409-FBD23637A789}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C39C115-ACBF-458A-9409-FBD23637A789}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B46ADCFF-35FF-496D-A035-FE2B9FFC185A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B46ADCFF-35FF-496D-A035-FE2B9FFC185A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B46ADCFF-35FF-496D-A035-FE2B9FFC185A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B46ADCFF-35FF-496D-A035-FE2B9FFC185A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F8EAC09-4BC7-43AA-B72B-48DDD2710F6D} = {8C29858C-623A-461A-BF0B-254E151CD9C2}
@@ -158,5 +172,7 @@ Global
{FA8DDDD1-4DD9-4927-A9FB-C4FACDEAF901} = {F21CCF39-1F8A-40DA-A0E5-F1426B09BAA2}
{6C233DE5-D1D0-46C0-A250-AF0272B495CE} = {79203C8D-F382-4C95-90EA-FECEE65602DA}
{5C39C115-ACBF-458A-9409-FBD23637A789} = {79203C8D-F382-4C95-90EA-FECEE65602DA}
+ {B46ADCFF-35FF-496D-A035-FE2B9FFC185A} = {9703A36A-A019-4ADC-93A7-9DF4EFBCBFBC}
+ {B1DA407F-DA29-4BDA-B10E-8B9A976B0C5E} = {9703A36A-A019-4ADC-93A7-9DF4EFBCBFBC}
EndGlobalSection
EndGlobal
From 630576c065beb54003e6deb1747a536267df24ea Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Sun, 10 Dec 2023 23:40:12 -0600
Subject: [PATCH 2/5] feat: solve part 1
---
10/PipeMaze.Tests/MazeTests.cs | 358 +++++++++++++++++++++++++++++++
10/PipeMaze.Tests/UnitTest1.cs | 10 -
10/PipeMaze/Program.cs | 374 ++++++++++++++++++++++++++++++++-
3 files changed, 730 insertions(+), 12 deletions(-)
create mode 100644 10/PipeMaze.Tests/MazeTests.cs
delete mode 100644 10/PipeMaze.Tests/UnitTest1.cs
diff --git a/10/PipeMaze.Tests/MazeTests.cs b/10/PipeMaze.Tests/MazeTests.cs
new file mode 100644
index 0000000..0172ba7
--- /dev/null
+++ b/10/PipeMaze.Tests/MazeTests.cs
@@ -0,0 +1,358 @@
+namespace PipeMaze.Tests;
+
+public class MazeTests
+{
+
+ [Theory]
+ [MemberData(nameof(TestData.ParseTestData), MemberType = typeof(TestData))]
+ public void Parse_WhenGivenInput_ItShouldReturnExpectedMaze(string[] input, Maze expectedMaze, Pipe? expectedStartingPipe)
+ {
+ var maze = Maze.Parse(input);
+ maze.Should().BeEquivalentTo(expectedMaze);
+ maze.StartingPipe.Should().BeEquivalentTo(expectedStartingPipe);
+ }
+
+ [Theory]
+ [MemberData(nameof(TestData.IdentifyPipeTypeTestData), MemberType = typeof(TestData))]
+ public void IdentifyPipeType_WhenGivenInput_ItShouldReturnExpectedPipeType(Maze maze, PipeType expectedPipeType)
+ {
+ maze
+ .IdentifyStartPipeType()
+ .Should()
+ .Be(expectedPipeType);
+ }
+
+ [Theory]
+ [MemberData(nameof(TestData.GetLoopTestData), MemberType = typeof(TestData))]
+ public void GetLoop_WhenGivenInput_ItShouldReturnExpectedLoop(Maze maze, List expectedLoop)
+ {
+ maze
+ .GetLoop()
+ .Should()
+ .BeEquivalentTo(expectedLoop);
+ }
+
+ [Theory]
+ [MemberData(nameof(TestData.FurthestStepFromStartTestData), MemberType = typeof(TestData))]
+ public void FurthestStepFromStart_WhenGivenInput_ItShouldReturnExpectedFurthestStepFromStart(Maze maze, int expectedFurthestStepFromStart)
+ {
+ maze.FarthestStepFromStart
+ .Should()
+ .Be(expectedFurthestStepFromStart);
+ }
+
+ public static class TestData
+ {
+ private static readonly string[] TestMazeInput =
+ {
+ ".....",
+ ".S-7.",
+ ".|.|.",
+ ".L-J.",
+ ".....",
+ };
+
+ private static readonly Maze TestMaze =
+ new(
+ 5,
+ 5,
+ [
+ new('S', PipeType.Unknown, 1, 1),
+ new('-', PipeType.LeftAndRight, 1, 2),
+ new('7', PipeType.DownAndLeft, 1, 3),
+ new('|', PipeType.UpAndDown, 2, 1),
+ new('|', PipeType.UpAndDown, 2, 3),
+ new('L', PipeType.UpAndRight, 3, 1),
+ new('-', PipeType.LeftAndRight, 3, 2),
+ new('J', PipeType.UpAndLeft, 3, 3),
+ ]
+ );
+
+ public static IEnumerable