Add AoC 2026 project templates

This commit is contained in:
Sebastian Lindemeier committed 2026-11-30 15:24:00 +01:00
1 parent 5e3bb81140
commit 132f8db999
7 files changed
+220

No files matched your search

+23
View File
@@ -26,6 +26,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions",
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.Extensions.Tests", "AdventOfCode.Extensions.Tests\AdventOfCode.Extensions.Tests.csproj", "{FCED95A0-13EC-4DB0-B572-592398BB30F3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.Extensions.Tests", "AdventOfCode.Extensions.Tests\AdventOfCode.Extensions.Tests.csproj", "{FCED95A0-13EC-4DB0-B572-592398BB30F3}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AoC_2026", "AoC_2026", "{92F94136-6D16-4740-ADD9-42C5376A30BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC_2026", "AoC_2026\AoC_2026.csproj", "{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC_2026.Runner", "AoC_2026.Runner\AoC_2026.Runner.csproj", "{0825C547-0498-43E1-8253-ACA7AC38DCA0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC_2026.Tests", "AoC_2026.Tests\AoC_2026.Tests.csproj", "{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -68,6 +76,18 @@ Global
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCED95A0-13EC-4DB0-B572-592398BB30F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.Build.0 = Release|Any CPU {FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.Build.0 = Release|Any CPU
{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A}.Release|Any CPU.Build.0 = Release|Any CPU
{0825C547-0498-43E1-8253-ACA7AC38DCA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0825C547-0498-43E1-8253-ACA7AC38DCA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0825C547-0498-43E1-8253-ACA7AC38DCA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0825C547-0498-43E1-8253-ACA7AC38DCA0}.Release|Any CPU.Build.0 = Release|Any CPU
{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{4F395AE3-DABB-4546-A4D0-5A62425FE168} = {05EBAA1C-B33B-4AFE-8635-A58D7CA509A7} {4F395AE3-DABB-4546-A4D0-5A62425FE168} = {05EBAA1C-B33B-4AFE-8635-A58D7CA509A7}
@@ -78,5 +98,8 @@ Global
{0249A329-D5C1-4699-88BE-A668B362432E} = {19D1A1FA-0E80-4C2C-A542-5AB6FB3FB18D} {0249A329-D5C1-4699-88BE-A668B362432E} = {19D1A1FA-0E80-4C2C-A542-5AB6FB3FB18D}
{1466A0F6-7C88-47FF-B8F8-FF30368E26DC} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61} {1466A0F6-7C88-47FF-B8F8-FF30368E26DC} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61}
{FCED95A0-13EC-4DB0-B572-592398BB30F3} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61} {FCED95A0-13EC-4DB0-B572-592398BB30F3} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61}
{01EE1F60-3E8C-4AAC-A2B6-1E995C460C8A} = {92F94136-6D16-4740-ADD9-42C5376A30BB}
{0825C547-0498-43E1-8253-ACA7AC38DCA0} = {92F94136-6D16-4740-ADD9-42C5376A30BB}
{D89E190D-8CB0-4E64-AACC-9C61F8FBFEDB} = {92F94136-6D16-4740-ADD9-42C5376A30BB}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
+14
View File
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AoC_2026\AoC_2026.csproj" />
</ItemGroup>
</Project>
+12
View File
@@ -0,0 +1,12 @@
// See https://aka.ms/new-console-template for more information
using System.Globalization;
using AoC_2026;
var rootPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var day01 = new Day01();
string day01Path = @$"{rootPath}\AoC-PuzzleInputs\2026\Prod\day01.txt";
Console.WriteLine(day01.SolvePart1(day01Path));
//Console.WriteLine(day01.SolvePart2(day01Path));
Console.WriteLine();
+25
View File
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
<PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AoC_2026\AoC_2026.csproj" />
</ItemGroup>
</Project>
+47
View File
@@ -0,0 +1,47 @@
using AdvenOfCode.Contracts;
namespace AoC_2026.Tests;
public class Day01Test
{
private readonly IPuzzleSolver<int> _sut;
private static readonly string rootPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
private readonly string TestInputPath = @$"{rootPath}/AoC-PuzzleInputs/2026/Test/day01.txt";
private readonly string ProdInputPath = @$"{rootPath}/AoC-PuzzleInputs/2026/Prod/day01.txt";
public Day01Test()
{
_sut = new Day01();
}
[Fact]
public void Part01_Test_equals_3()
{
var actual = _sut.SolvePart1(TestInputPath);
Assert.Equal(3, actual);
}
[Fact]
public void Part01_Prod_equals_1097()
{
var actual = _sut.SolvePart1(ProdInputPath);
Assert.Equal(1097, actual);
}
[Fact]
public void Part02_Test_equals_16()
{
var actual = _sut.SolvePart2(TestInputPath);
Assert.Equal(16, actual);
}
[Fact]
public void Part02_Prod_equals_7101()
{
var actual = _sut.SolvePart2(ProdInputPath);
Assert.Equal(7101, actual);
}
}
+15
View File
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AdvenOfCode.Contracts\AdvenOfCode.Contracts.csproj" />
<ProjectReference Include="..\AdventOfCode.Extensions\AdventOfCode.Extensions.csproj" />
<ProjectReference Include="..\AdventOfCode.HelperClasses\AdventOfCode.HelperClasses.csproj" />
</ItemGroup>
</Project>
+84
View File
@@ -0,0 +1,84 @@
using AdvenOfCode.Contracts;
namespace AoC_2026;
public class Day01 : IPuzzleSolver<int>
{
private string[] ParsePuzzleInput(string path)
{
var puzzleInput = File.ReadAllLines(path)
.Where(l => !string.IsNullOrWhiteSpace(l))
.ToArray();
return puzzleInput;
}
public int SolvePart1(string pathToPuzzleInput)
{
var rotationInstructions = ParsePuzzleInput(pathToPuzzleInput);
var dialPosition = 50;
var timesZeroWasHit = 0;
foreach (var rotationAmount in rotationInstructions.Select(ParseRotationAmount))
{
dialPosition = (dialPosition + rotationAmount) % 100;
if (dialPosition == 0)
timesZeroWasHit++;
}
return timesZeroWasHit;
}
public int SolvePart2(string pathToPuzzleInput)
{
var rotationInstructions = ParsePuzzleInput(pathToPuzzleInput);
var dialPosition = 50;
var timesZeroWasHit = 0;
foreach (var rotationAmount in rotationInstructions.Select(ParseRotationAmount))
{
var actualRotationAmount = 0;
if (rotationAmount < 0)
{
(var fullTurns, actualRotationAmount) = DivMod(rotationAmount, -100);
timesZeroWasHit += fullTurns;
if (dialPosition != 0 && dialPosition + actualRotationAmount <= 0)
timesZeroWasHit++;
}
else
{
(var fullTurns, actualRotationAmount) = DivMod(rotationAmount, 100);
timesZeroWasHit += fullTurns;
if (dialPosition + actualRotationAmount >= 100)
timesZeroWasHit++;
}
dialPosition = Mod(dialPosition + actualRotationAmount, 100);
}
return timesZeroWasHit;
}
private (int div, int mod) DivMod(int number, int divisor)
{
return (number / divisor, Mod(number, divisor));
}
private int Mod(int number, int divident)
{
var mod = number % divident;
if (number < 0 && divident > 0)
{
mod = divident + mod;
}
return mod;
}
private static int ParseRotationAmount(string puzzleInput)
{
var direction = puzzleInput[..1];
var rotationAmount = int.Parse(puzzleInput[1..]);
if (direction == "L")
{
rotationAmount *= -1;
}
return rotationAmount;
}
}