| 1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace Day23;
- public class Tile
- {
- public char Value { get; }
- public Vec Position { get; }
- public IList<PathNode> Incoming { get; } = new List<PathNode>();
- public IList<PathNode> Outgoing { get; } = new List<PathNode>();
- public bool IsPath => Value == '.' || IsArrow;
- public bool IsArrow => Value == '<' || Value == '>' || Value == '^' || Value == 'v';
- public Tile(char value, Vec position)
- {
- Value = value;
- Position = position;
- }
- public IEnumerable<Vec> Neighbors()
- {
- yield return Position.Add(Vec.Up);
- yield return Position.Add(Vec.Right);
- yield return Position.Add(Vec.Down);
- yield return Position.Add(Vec.Left);
- }
- public Vec ArrowDirection()
- {
- return Value switch
- {
- '^' => Vec.Up,
- 'v' => Vec.Down,
- '<' => Vec.Left,
- '>' => Vec.Right,
- _ => Vec.Zero
- };
- }
- }
|