| 123456789101112131415161718192021222324252627282930313233343536 |
- namespace Day17;
- public class Path
- {
- public Path? Prev { get; }
- public Tile Tile { get; }
- public Vec VRun { get; }
- public int LRun { get; }
- public int Cost { get; }
-
- public Path(Path? prev, Tile tile, Vec vRun)
- {
- Prev = prev;
- Tile = tile;
-
- VRun = vRun;
- LRun = vRun == Prev?.VRun ? Prev!.LRun + 1 : 1;
- Cost = (prev?.Cost ?? 0) + tile.Cost;
- }
- public IEnumerable<Vec> Next()
- {
- yield return VRun.RotatePositive();
- if (LRun < 3)
- {
- yield return VRun;
- }
- yield return VRun.RotateNegative();
- }
- public string GetKey()
- {
- return $"{Tile.Position.X}/{Tile.Position.Y},{VRun.X}/{VRun.Y},{LRun}";
- }
- }
|