Compare commits
4 Commits
cf4bc005d5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a653f07669 | |||
| 1649440a6e | |||
| 86947a6e6d | |||
| 08d495907f |
@@ -32,6 +32,14 @@
|
|||||||
<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>
|
||||||
|
<None Remove="Input\DaySeven.txt" />
|
||||||
|
<Content Include="Input\DaySeven.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
32
AdventOfCode2025/Laboratories.cs
Normal file
32
AdventOfCode2025/Laboratories.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using AdventOfCode2025.Utils;
|
||||||
|
|
||||||
|
namespace AdventOfCode2025;
|
||||||
|
|
||||||
|
public class Laboratories : IAdventSolution
|
||||||
|
{
|
||||||
|
public AdventSolution Solve(string input)
|
||||||
|
{
|
||||||
|
var lines = input.SplitLines();
|
||||||
|
var start = lines[0].IndexOf('S');
|
||||||
|
var splitters = new HashSet<Coordinate>();
|
||||||
|
var origin = new Coordinate(start, 0);
|
||||||
|
Traverse(lines, origin, splitters);
|
||||||
|
return new AdventSolution(splitters.Count.ToString(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Traverse(string[] map, Coordinate start, HashSet<Coordinate> splitters)
|
||||||
|
{
|
||||||
|
if (start.X < 0 || start.X >= map[0].Length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (var y = start.Y; y < map.Length; y++)
|
||||||
|
{
|
||||||
|
if (map[y][start.X] != '^') continue;
|
||||||
|
if (!splitters.Add(new Coordinate(start.X, y))) return;
|
||||||
|
|
||||||
|
Traverse(map, new Coordinate(start.X + 1, y), splitters);
|
||||||
|
Traverse(map, new Coordinate(start.X - 1, y), splitters);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,4 +15,10 @@ var dayFourInput = await File.ReadAllTextAsync("./Input/DayFour.txt");
|
|||||||
AdventSolver<PrintingDepartment>.Solve(dayFourInput, 4, "Printing Department");
|
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, 4, "Cafeteria");
|
AdventSolver<Cafeteria>.Solve(dayFiveInput, 5, "Cafeteria");
|
||||||
|
|
||||||
|
var daySixInput = await File.ReadAllTextAsync("./Input/DaySix.txt");
|
||||||
|
AdventSolver<TrashCompactor>.Solve(daySixInput, 6, "Trash Compactor");
|
||||||
|
|
||||||
|
var daySevenInput = await File.ReadAllTextAsync("./Input/DaySeven.txt");
|
||||||
|
AdventSolver<Laboratories>.Solve(daySevenInput, 7, "Laboratories");
|
||||||
34
AdventOfCode2025/TrashCompactor.cs
Normal file
34
AdventOfCode2025/TrashCompactor.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user