Julian Gonzalez

Generation

generate functionSat, 01 Apr 2023

travel array with two dimensions c#

public class VisitedArray { bool[,] visited; List<(int, int)> path = new List<(int, int)>(); public List<(int, int)> GetPath(bool[,] visited) { this.visited = visited; GetPath(0, 0); return path; } public bool GetPath(int i, int j) { if (i == visited.GetLength(0) - 1 && j == visited.GetLength(1) - 1) { path.Add((i, j)); return true; } if (i >= visited.GetLength(0) || j >= visited.GetLength(1) || visited[i, j]) { return false; } visited[i, j] = true; if (GetPath(i + 1, j)) { path.Add((i, j)); return true; } if (GetPath(i, j + 1)) { path.Add((

Questions about programming?Chat with your personal AI assistant