Compare commits

...

2 Commits

Author SHA1 Message Date
86947a6e6d completed part 1 2025-12-06 00:35:50 -05:00
08d495907f prep for day 6 2025-12-06 00:20:40 -05:00
3 changed files with 42 additions and 1 deletions

View File

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

View File

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

View File

@@ -0,0 +1,34 @@
using AdventOfCode2025.Utils;
namespace AdventOfCode2025;
public class TrashCompactor : IAdventSolution
{
public AdventSolution Solve(string input)
{
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);
}
}