completed part 1
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -17,5 +17,5 @@ AdventSolver<PrintingDepartment>.Solve(dayFourInput, 4, "Printing Department");
|
||||
var dayFiveInput = await File.ReadAllTextAsync("./Input/DayFive.txt");
|
||||
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");
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user