コード例 #1
0
 /// <summary>
 /// Calculates the Manhattan distance to other.
 /// </summary>
 /// <param name="other">The other position.</param>
 /// <returns>The Manhattan distance to other.</returns>
 public int CalcManhattanDistance(X_Y other)
 {
     return(Math.Abs(other.X - this.X) + Math.Abs(other.Y - this.Y));
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: AlexChernov/adventofcode
 /// <summary>
 /// Determines whether an positin in bound of data.
 /// </summary>
 /// <typeparam name="T">The type of data.</typeparam>
 /// <param name="data">The 2D array of data.</param>
 /// <param name="xy">The instance of <see cref="X_Y"/> with position to check.</param>
 /// <returns>True if the positon in bound; otherwise False is returned.</returns>
 public static bool InBound <T>(this T[,] data, X_Y xy)
 {
     return(xy.X >= 0 && xy.X < data.GetLength(0) && xy.Y >= 0 && xy.Y < data.GetLength(1));
 }