Example #1
0
        public static IEnumerable <AoCPoint> Adjacent(this AoCPoint point, bool diagonal)
        {
            if (diagonal)
            {
                yield return(point.Up().Left());
            }
            yield return(point.Up());

            if (diagonal)
            {
                yield return(point.Up().Right());
            }
            yield return(point.Right());

            if (diagonal)
            {
                yield return(point.Down().Right());
            }
            yield return(point.Down());

            if (diagonal)
            {
                yield return(point.Down().Left());
            }
            yield return(point.Left());
        }
Example #2
0
        public static IEnumerable <AoCPoint> Adjacent(this AoCPoint point)
        {
            yield return(point.Up());

            yield return(point.Right());

            yield return(point.Down());

            yield return(point.Left());
        }
Example #3
0
 public static AoCPoint Left(this AoCPoint point) => new AoCPoint(point.X - 1, point.Y);
Example #4
0
 public static AoCPoint Down(this AoCPoint point) => new AoCPoint(point.X, point.Y + 1);
 public static int GetManhattanDistance(AoCPoint p, int x, int y) => GetManhattanDistance(p.X, p.Y, x, y);
 public static int GetManhattanDistance(AoCPoint p1, AoCPoint p2) => GetManhattanDistance(p1.X, p1.Y, p2.X, p2.Y);