diff --git a/AdventOfCode2025/AdventOfCode2025.csproj b/AdventOfCode2025/AdventOfCode2025.csproj index 98b42fc..8699045 100644 --- a/AdventOfCode2025/AdventOfCode2025.csproj +++ b/AdventOfCode2025/AdventOfCode2025.csproj @@ -32,6 +32,10 @@ PreserveNewest + + + PreserveNewest + diff --git a/AdventOfCode2025/Program.cs b/AdventOfCode2025/Program.cs index 8b1a9ba..b3a385a 100644 --- a/AdventOfCode2025/Program.cs +++ b/AdventOfCode2025/Program.cs @@ -17,5 +17,5 @@ AdventSolver.Solve(dayFourInput, 4, "Printing Department"); var dayFiveInput = await File.ReadAllTextAsync("./Input/DayFive.txt"); AdventSolver.Solve(dayFiveInput, 5, "Cafeteria"); -var daySixInput = await File.ReadAllTextAsync("./Input/Test.txt"); +var daySixInput = await File.ReadAllTextAsync("./Input/DaySix.txt"); AdventSolver.Solve(daySixInput, 6, "Trash Compactor"); \ No newline at end of file diff --git a/AdventOfCode2025/TrashCompactor.cs b/AdventOfCode2025/TrashCompactor.cs index 3808fff..c47bd13 100644 --- a/AdventOfCode2025/TrashCompactor.cs +++ b/AdventOfCode2025/TrashCompactor.cs @@ -1,9 +1,34 @@ -namespace AdventOfCode2025; +using AdventOfCode2025.Utils; + +namespace AdventOfCode2025; public class TrashCompactor : IAdventSolution { 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); } } \ No newline at end of file