Add day 15

This commit is contained in:
2022-12-17 15:16:52 +01:00
parent 0dfc6b59de
commit aa833569da
2 changed files with 290 additions and 4 deletions

View File

@@ -118,7 +118,7 @@ public class Day14 : Day
public override int Number => 14;
public override string Name => "Regolith Reservoir";
private Point _sandSource = new(500, 0);
private readonly Point _sandSource = new(500, 0);
private Point _offsetSandSource;
public override void RunPart1()
@@ -161,7 +161,7 @@ public class Day14 : Day
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
}
private bool GenerateSand(CellType[,] map, Canvas canvas, in Point sandSource)
private static bool GenerateSand(CellType[,] map, Canvas canvas, in Point sandSource)
{
// Stop if source is blocked
if (map[sandSource.X, sandSource.Y] == CellType.Sand)
@@ -230,7 +230,7 @@ public class Day14 : Day
return true;
}
private bool GenerateSand(IDictionary<Point, CellType> map, in Point sandSource, int groundY)
private static bool GenerateSand(IDictionary<Point, CellType> map, in Point sandSource, int groundY)
{
// Stop if source is blocked
if (map.GetValueOrDefault(sandSource, CellType.Air) == CellType.Sand)
@@ -374,7 +374,7 @@ public class Day14 : Day
};
}
private IDictionary<Point, CellType> GenerateDictionaryMap()
private static IDictionary<Point, CellType> GenerateDictionaryMap()
{
var paths = Input.ReadAllLines()
.Select(line => new MapPath(line.Split(" -> ")