From e37fbc977cbdb847b2248f56979d1e4e731f7a86 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Mon, 18 Dec 2023 11:01:37 -0600
Subject: [PATCH 1/5] chore: stub out puzzle problem, input, and solution
---
13/PointOfIncidence.Tests/GlobalUsings.cs | 2 ++
.../PointOfIncidence.Tests.csproj | 30 +++++++++++++++++++
13/PointOfIncidence.Tests/UnitTest1.cs | 10 +++++++
13/PointOfIncidence/PointOfIncidence.csproj | 10 +++++++
13/PointOfIncidence/Program.cs | 2 ++
AdventOfCode2023.sln | 16 ++++++++++
6 files changed, 70 insertions(+)
create mode 100644 13/PointOfIncidence.Tests/GlobalUsings.cs
create mode 100644 13/PointOfIncidence.Tests/PointOfIncidence.Tests.csproj
create mode 100644 13/PointOfIncidence.Tests/UnitTest1.cs
create mode 100644 13/PointOfIncidence/PointOfIncidence.csproj
create mode 100644 13/PointOfIncidence/Program.cs
diff --git a/13/PointOfIncidence.Tests/GlobalUsings.cs b/13/PointOfIncidence.Tests/GlobalUsings.cs
new file mode 100644
index 0000000..7fef4b0
--- /dev/null
+++ b/13/PointOfIncidence.Tests/GlobalUsings.cs
@@ -0,0 +1,2 @@
+global using Xunit;
+global using FluentAssertions;
\ No newline at end of file
diff --git a/13/PointOfIncidence.Tests/PointOfIncidence.Tests.csproj b/13/PointOfIncidence.Tests/PointOfIncidence.Tests.csproj
new file mode 100644
index 0000000..8c7a13b
--- /dev/null
+++ b/13/PointOfIncidence.Tests/PointOfIncidence.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/13/PointOfIncidence.Tests/UnitTest1.cs b/13/PointOfIncidence.Tests/UnitTest1.cs
new file mode 100644
index 0000000..df19976
--- /dev/null
+++ b/13/PointOfIncidence.Tests/UnitTest1.cs
@@ -0,0 +1,10 @@
+namespace PointOfIncidence.Tests;
+
+public class UnitTest1
+{
+ [Fact]
+ public void Test1()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/13/PointOfIncidence/PointOfIncidence.csproj b/13/PointOfIncidence/PointOfIncidence.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/13/PointOfIncidence/PointOfIncidence.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/13/PointOfIncidence/Program.cs b/13/PointOfIncidence/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/13/PointOfIncidence/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 741151e..90f8bdb 100644
--- a/AdventOfCode2023.sln
+++ b/AdventOfCode2023.sln
@@ -75,6 +75,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotSprings", "12\HotSprings
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotSprings.Tests", "12\HotSprings.Tests\HotSprings.Tests.csproj", "{2731DE56-AF4B-4009-8259-2EA5A9A102FE}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "13", "13", "{DC4E691A-0061-4937-8732-E8D8073C868D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfIncidence", "13\PointOfIncidence\PointOfIncidence.csproj", "{334D6DFF-6131-49C1-B54C-B9E8E00F1E3E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfIncidence.Tests", "13\PointOfIncidence.Tests\PointOfIncidence.Tests.csproj", "{0E74E842-A876-4E8C-9D10-BA09F40039EC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -180,6 +186,14 @@ Global
{2731DE56-AF4B-4009-8259-2EA5A9A102FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2731DE56-AF4B-4009-8259-2EA5A9A102FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2731DE56-AF4B-4009-8259-2EA5A9A102FE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {334D6DFF-6131-49C1-B54C-B9E8E00F1E3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {334D6DFF-6131-49C1-B54C-B9E8E00F1E3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {334D6DFF-6131-49C1-B54C-B9E8E00F1E3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {334D6DFF-6131-49C1-B54C-B9E8E00F1E3E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0E74E842-A876-4E8C-9D10-BA09F40039EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0E74E842-A876-4E8C-9D10-BA09F40039EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0E74E842-A876-4E8C-9D10-BA09F40039EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0E74E842-A876-4E8C-9D10-BA09F40039EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F8EAC09-4BC7-43AA-B72B-48DDD2710F6D} = {8C29858C-623A-461A-BF0B-254E151CD9C2}
@@ -206,5 +220,7 @@ Global
{0D6CD658-65BB-47DC-A865-E3428EBE3075} = {01A6D73F-996E-48B3-B111-2725016A49C2}
{DB4A8A1F-54A8-4534-AE0A-027B365AA73B} = {ABF03698-B81C-45DE-B76A-C7FBC0C72DB6}
{2731DE56-AF4B-4009-8259-2EA5A9A102FE} = {ABF03698-B81C-45DE-B76A-C7FBC0C72DB6}
+ {334D6DFF-6131-49C1-B54C-B9E8E00F1E3E} = {DC4E691A-0061-4937-8732-E8D8073C868D}
+ {0E74E842-A876-4E8C-9D10-BA09F40039EC} = {DC4E691A-0061-4937-8732-E8D8073C868D}
EndGlobalSection
EndGlobal
From 92e3e32d0b5484b4062f99cf850ccfbcf1c2da03 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Mon, 18 Dec 2023 22:51:12 -0600
Subject: [PATCH 2/5] feat: solve part 1
---
13/PointOfIncidence.Tests/PatternTests.cs | 160 +++++++++++++
.../PointOfIncidence.Tests.csproj | 12 +
13/PointOfIncidence.Tests/UnitTest1.cs | 10 -
13/PointOfIncidence/Program.cs | 214 +++++++++++++++++-
4 files changed, 384 insertions(+), 12 deletions(-)
create mode 100644 13/PointOfIncidence.Tests/PatternTests.cs
delete mode 100644 13/PointOfIncidence.Tests/UnitTest1.cs
diff --git a/13/PointOfIncidence.Tests/PatternTests.cs b/13/PointOfIncidence.Tests/PatternTests.cs
new file mode 100644
index 0000000..5022129
--- /dev/null
+++ b/13/PointOfIncidence.Tests/PatternTests.cs
@@ -0,0 +1,160 @@
+namespace PointOfIncidence.Tests;
+
+public class PatternTests
+{
+ [Theory]
+ [MemberData(nameof(TestData.ParseTestData), MemberType = typeof(TestData))]
+ public void Parse_GivenAPattern_ItShouldReturnPatternInstance(string[] input, Pattern expected)
+ {
+ var result = Pattern.Parse(input);
+ result.Should().BeEquivalentTo(expected);
+ }
+
+ [Theory]
+ [MemberData(nameof(TestData.FindPointOfReflectionTestData), MemberType = typeof(TestData))]
+ public void FindPointOfReflection_GivenAPattern_ItShouldReturnPointOfReflection(string[] input, PointOfReflection expected)
+ {
+ var pattern = Pattern.Parse(input);
+ var result = pattern.FindPointOfReflection();
+ result.Should().BeEquivalentTo(expected);
+ }
+
+ [Fact]
+ public void SummarizePatternNotes_GivenExampleInput_ItShouldReturnExpectedValue()
+ {
+ var input = File
+ .ReadAllText("EXAMPLE.txt")
+ .ReplaceLineEndings();
+
+ var patterns = input
+ .Split(Environment.NewLine + Environment.NewLine)
+ .Select(p => p.Split(Environment.NewLine));
+
+ var result = patterns
+ .Select(Pattern.Parse)
+ .Sum(p => p.SummarizePatternNotes());
+
+ result.Should().Be(405);
+ }
+
+
+ [Fact]
+ public void SummarizePatternNotes_GivenInput_ItShouldReturnExpectedValue()
+ {
+ var input = File
+ .ReadAllText("INPUT.txt")
+ .ReplaceLineEndings();
+
+ var patterns = input
+ .Split(Environment.NewLine + Environment.NewLine)
+ .Select(p => p.Split(Environment.NewLine));
+
+ var result = patterns
+ .Select(Pattern.Parse)
+ .Select(p => p.SummarizePatternNotes())
+ .Sum();
+
+ result.Should().Be(33728);
+ }
+
+ public static class TestData
+ {
+ public static IEnumerable