feat: solved part 1
This commit is contained in:
@@ -27,4 +27,10 @@
|
|||||||
<ProjectReference Include="..\CubeConundrum\CubeConundrum.csproj" />
|
<ProjectReference Include="..\CubeConundrum\CubeConundrum.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\INPUT.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace CubeConundrum.Tests;
|
||||||
|
|
||||||
|
public class ProgramTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task Main_GivenInput_ItShouldReturnExpectedSum()
|
||||||
|
{
|
||||||
|
var result = await Program.Main(["INPUT.txt"]);
|
||||||
|
result.Should().Be(2879);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,28 @@ public class Program
|
|||||||
{
|
{
|
||||||
public async static Task<int> Main(string[] args)
|
public async static Task<int> Main(string[] args)
|
||||||
{
|
{
|
||||||
return await Task.FromResult(0);
|
if (args.Length is 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please provide a path to the input file.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(args[0]) is false)
|
||||||
|
{
|
||||||
|
Console.WriteLine("The provided file does not exist.");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
var puzzleParser = new PuzzleParser();
|
||||||
|
var puzzleSolver = new PartOnePuzzleSolver();
|
||||||
|
|
||||||
|
var input = await File.ReadAllLinesAsync(args[0]);
|
||||||
|
var games = input.Select(puzzleParser.ParseGame);
|
||||||
|
var result = puzzleSolver.SumPossibleGameIds(games);
|
||||||
|
|
||||||
|
Console.WriteLine($"The sum of all possible game ids is {result}.");
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user