feat: solve part 1 and part 2 of puzzle 6
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
namespace WaitForIt.Tests;
|
||||
|
||||
public class ProgramTests
|
||||
{
|
||||
public void Main_WhenGivenInput_ItShouldReturnTheProductOfTheMarginOfErrors()
|
||||
{
|
||||
var result = Program.Main(["INPUT.txt"]);
|
||||
result.Should().Be(1710720);
|
||||
}
|
||||
|
||||
public void Main_WhenGivenInputAndPart2_ItShouldReturnTheNumberOfWaysToWin()
|
||||
{
|
||||
var result = Program.Main(["INPUT.txt", "part2"]);
|
||||
result.Should().Be(35349468);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace WaitForIt.Tests;
|
||||
|
||||
public class PuzzleParserTests
|
||||
{
|
||||
private readonly PuzzleParser _sut = new();
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TestData.ValidInputData), MemberType = typeof(TestData))]
|
||||
public void Parse_WhenGivenValidInput_ItShouldReturnAListOfRaces(string[] input, List<Race> expected)
|
||||
{
|
||||
var result = _sut.ParseRaces(input);
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
}
|
||||
|
||||
public static class TestData
|
||||
{
|
||||
private static readonly string[] ValidInput =
|
||||
[
|
||||
"Time: 7 15 30",
|
||||
"Distance: 9 40 200"
|
||||
];
|
||||
|
||||
public static IEnumerable<object[]> ValidInputData =>
|
||||
new List<object[]>
|
||||
{
|
||||
new object[]
|
||||
{
|
||||
ValidInput,
|
||||
new List<Race>
|
||||
{
|
||||
new(7, 9),
|
||||
new(15, 40),
|
||||
new(30, 200)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace WaitForIt.Tests;
|
||||
|
||||
public class RaceTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(7, 9, 4)]
|
||||
[InlineData(15, 40, 8)]
|
||||
[InlineData(30, 200, 9)]
|
||||
public void CalculateNumberOfWaysToWin_WhenCalled_ItShouldReturnNumberOfWaysToWin(int raceDuration, int distanceRecord, int expected)
|
||||
{
|
||||
var result = new Race(raceDuration, distanceRecord).CalculateNumberOfWaysToWin();
|
||||
result.Should().Be(expected);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace WaitForIt.Tests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,10 @@
|
||||
<ProjectReference Include="..\WaitForIt\WaitForIt.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\INPUT.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user