generated from eduherminio/AdventOfCode.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c70269
commit 506e2ba
Showing
16 changed files
with
1,807 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,3 +348,5 @@ MigrationBackup/ | |
|
||
# Ionide (cross platform F# VS Code tools) working folder | ||
.ionide/ | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="Shouldly" Version="4.2.1"/> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AdventOfCode\AdventOfCode.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace AdventOfCode.Tests; | ||
|
||
public class DayTests | ||
{ | ||
[Fact] | ||
public void Day01_01_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"1abc2", | ||
"pqr3stu8vwx", | ||
"a1b2c3d4e5f", | ||
"treb7uchet" | ||
}); | ||
|
||
var day = new Day01(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_1() | ||
.Result; | ||
result.ShouldBe("142"); | ||
} | ||
|
||
[Fact] | ||
public void Day01_02_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"two1nine", | ||
"eightwothree", | ||
"abcone2threexyz", | ||
"xtwone3four", | ||
"4nineeightseven2", | ||
"zoneight234", | ||
"7pqrstsixteen" | ||
}); | ||
|
||
var day = new Day01(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_2() | ||
.Result; | ||
result.ShouldBe("281"); | ||
} | ||
|
||
[Fact] | ||
public void Day02_01_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green", | ||
"Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue", | ||
"Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red", | ||
"Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red", | ||
"Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green" | ||
}); | ||
|
||
var day = new Day02(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_1() | ||
.Result; | ||
result.ShouldBe("8"); | ||
} | ||
|
||
[Fact] | ||
public void Day02_02_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green", | ||
"Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue", | ||
"Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red", | ||
"Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red", | ||
"Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green" | ||
}); | ||
|
||
var day = new Day02(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_2() | ||
.Result; | ||
result.ShouldBe("2286"); | ||
} | ||
|
||
[Fact] | ||
public void Day03_01_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"467..114..", | ||
"...*......", | ||
"..35..633.", | ||
"......#...", | ||
"617*......", | ||
".....+.58.", | ||
"..592.....", | ||
"......755.", | ||
"...$.*....", | ||
".664.598.." | ||
}); | ||
|
||
var day = new Day03(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_1() | ||
.Result; | ||
result.ShouldBe("4361"); | ||
} | ||
|
||
[Fact] | ||
public void Day03_02_Test1() | ||
{ | ||
var strList = string.Join("\r\n", new List<string> | ||
{ | ||
"467..114..", | ||
"...*......", | ||
"..35..633.", | ||
"......#...", | ||
"617*......", | ||
".....+.58.", | ||
"..592.....", | ||
"......755.", | ||
"...$.*....", | ||
".664.598.." | ||
}); | ||
|
||
var day = new Day03(); | ||
day.IsTest = true; | ||
day.TestInput = strList; | ||
var result = day.Solve_2() | ||
.Result; | ||
result.ShouldBe("467835"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AoCHelper" Version="3.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="AoCHelper" Version="3.0.0"/> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<NoWarn>S101</NoWarn> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<NoWarn>S101</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Inputs\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="Inputs\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Inputs\03.txt"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.IO; | ||
using AoCHelper; | ||
|
||
namespace AdventOfCode.Core; | ||
|
||
public abstract class BetterBaseDay : BaseDay | ||
{ | ||
public bool IsTest { get; set; } = false; | ||
public string TestInput { get; set; } | ||
protected string InputData => GetData(); | ||
|
||
private string GetData() | ||
{ | ||
return IsTest ? TestInput : File.ReadAllText(InputFilePath); | ||
} | ||
} |
Oops, something went wrong.