diff --git a/AdventOfCode2025/AdventOfCode2025.csproj b/AdventOfCode2025/AdventOfCode2025.csproj index 152fed4..7a10560 100644 --- a/AdventOfCode2025/AdventOfCode2025.csproj +++ b/AdventOfCode2025/AdventOfCode2025.csproj @@ -24,6 +24,10 @@ PreserveNewest + + + PreserveNewest + diff --git a/AdventOfCode2025/PrintingDepartment.cs b/AdventOfCode2025/PrintingDepartment.cs index 6b0730b..d77beed 100644 --- a/AdventOfCode2025/PrintingDepartment.cs +++ b/AdventOfCode2025/PrintingDepartment.cs @@ -1,9 +1,44 @@ -namespace AdventOfCode2025; +using AdventOfCode2025.Utils; + +namespace AdventOfCode2025; public class PrintingDepartment : IAdventSolution { + private readonly HashSet _existingRolls = new(); public AdventSolution Solve(string input) { - throw new NotImplementedException(); + var map = input.SplitLines(); + for (var i = 0; i < map.Length; i++) + { + for (var j = 0; j < map[i].Length; j++) + { + if(map[i][j] != '.') + _existingRolls.Add(new Coordinate(j, i)); + } + } + + var accessible = 0; + foreach (var c in _existingRolls) + { + if(IsAccessible(c)) accessible++; + } + + return new AdventSolution(accessible.ToString(), null); + } + + private readonly Coordinate[] _directions = + [ + new(-1, -1), new( 0, -1), new( 1, -1), + new(-1, 0), new( 1, 0), + new(-1, 1), new( 0, 1), new( 1, 1) + ]; + private bool IsAccessible(Coordinate position) + { + var neighbors = 0; + foreach (var dir in _directions) + { + if(_existingRolls.Contains(position + dir)) neighbors++; + } + return neighbors < 4; } } \ No newline at end of file diff --git a/AdventOfCode2025/Program.cs b/AdventOfCode2025/Program.cs index 7fab97f..1f40374 100644 --- a/AdventOfCode2025/Program.cs +++ b/AdventOfCode2025/Program.cs @@ -11,5 +11,5 @@ AdventSolver.Solve(dayTwoInput, 2, "Gift Shop"); var dayThreeInput = await File.ReadAllTextAsync("./Input/DayThree.txt"); AdventSolver.Solve(dayThreeInput, 3, "Lobby"); -var dayFourInput = await File.ReadAllTextAsync("./Input/Test.txt"); +var dayFourInput = await File.ReadAllTextAsync("./Input/DayFour.txt"); AdventSolver.Solve(dayFourInput, 4, "Printing Department"); \ No newline at end of file