completed part 1

This commit is contained in:
2025-12-06 00:35:50 -05:00
parent 08d495907f
commit 86947a6e6d
3 changed files with 32 additions and 3 deletions

View File

@@ -32,6 +32,10 @@
<Content Include="Input\DayFive.txt"> <Content Include="Input\DayFive.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Remove="Input\DaySix.txt" />
<Content Include="Input\DaySix.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -17,5 +17,5 @@ AdventSolver<PrintingDepartment>.Solve(dayFourInput, 4, "Printing Department");
var dayFiveInput = await File.ReadAllTextAsync("./Input/DayFive.txt"); var dayFiveInput = await File.ReadAllTextAsync("./Input/DayFive.txt");
AdventSolver<Cafeteria>.Solve(dayFiveInput, 5, "Cafeteria"); AdventSolver<Cafeteria>.Solve(dayFiveInput, 5, "Cafeteria");
var daySixInput = await File.ReadAllTextAsync("./Input/Test.txt"); var daySixInput = await File.ReadAllTextAsync("./Input/DaySix.txt");
AdventSolver<TrashCompactor>.Solve(daySixInput, 6, "Trash Compactor"); AdventSolver<TrashCompactor>.Solve(daySixInput, 6, "Trash Compactor");

View File

@@ -1,9 +1,34 @@
namespace AdventOfCode2025; using AdventOfCode2025.Utils;
namespace AdventOfCode2025;
public class TrashCompactor : IAdventSolution public class TrashCompactor : IAdventSolution
{ {
public AdventSolution Solve(string input) public AdventSolution Solve(string input)
{ {
throw new NotImplementedException(); var lines = input.SplitLines();
var operators = lines[^1].Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
var results = new ulong[operators.Length];
for (var i = 0; i < lines.Length - 1; i++)
{
var line = lines[i].Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
for (var j = 0; j < line.Length; j++)
{
if(i == 0)
results[j] = ulong.Parse(line[j]);
else switch (operators[j])
{
case "+":
results[j] += ulong.Parse(line[j]);
break;
case "*":
results[j] *= ulong.Parse(line[j]);
break;
}
}
}
var sum = results.Aggregate(0UL, (current, result) => current + result);
return new AdventSolution(sum.ToString(),null);
} }
} }