feat: solved day 16 part 2

This commit is contained in:
Stevan Freeborn
2024-12-17 22:58:51 -06:00
parent 5b7dbd5b1d
commit 655b1ffd8f
8 changed files with 209 additions and 88 deletions
+66 -3
View File
@@ -2,11 +2,26 @@
public class PuzzleSolverTests
{
private async Task<string[]> GetPuzzleInput()
{
return await File.ReadAllLinesAsync(Path.Combine(AppContext.BaseDirectory, "INPUT.txt"));
}
[Test]
public async Task PartOneSolution_WhenCalledWithInput_ItShouldReturnExpectedValue()
{
var input = await GetPuzzleInput();
var result = PuzzleSolver.Solve(input);
await Assert.That(result).IsEqualTo(90460);
}
[Test]
[MethodDataSource(nameof(SolveTestCases))]
public async Task Solve_WhenCalledWithInput_ItShouldReturnExpectedValue(SolveTestCase testCase)
{
var result = PuzzleSolver.Solve(testCase.Input);
var result = PuzzleSolver.Solve(testCase.Input, testCase.IsPart2);
await Assert.That(result).IsEqualTo(testCase.ExpectedValue);
}
@@ -30,7 +45,8 @@ public class PuzzleSolverTests
"#.###.#.#.#.#.#",
"#S..#.....#...#",
"###############",
],
],
false,
7036
);
@@ -54,9 +70,56 @@ public class PuzzleSolverTests
"#S#.............#",
"#################",
],
false,
11048
);
yield return () => new(
[
"###############",
"#.......#....E#",
"#.#.###.#.###.#",
"#.....#.#...#.#",
"#.###.#####.#.#",
"#.#.#.......#.#",
"#.#.#####.###.#",
"#...........#.#",
"###.#.#####.#.#",
"#...#.....#.#.#",
"#.#.#.###.#.#.#",
"#.....#...#.#.#",
"#.###.#.#.#.#.#",
"#S..#.....#...#",
"###############",
],
true,
45
);
yield return () => new(
[
"#################",
"#...#...#...#..E#",
"#.#.#.#.#.#.#.#.#",
"#.#.#.#...#...#.#",
"#.#.#.#.###.#.#.#",
"#...#.#.#.....#.#",
"#.#.#.#.#.#####.#",
"#.#...#.#.#.....#",
"#.#.#####.#.###.#",
"#.#.#.......#...#",
"#.#.###.#####.###",
"#.#.#...#.....#.#",
"#.#.#.#####.###.#",
"#.#.#.........#.#",
"#.#.#.#########.#",
"#S#.............#",
"#################",
],
true,
64
);
}
public record SolveTestCase(string[] Input, int ExpectedValue);
public record SolveTestCase(string[] Input, bool IsPart2, int ExpectedValue);
}