private static Map ReadMap(string fileName) { var mapPath = Path.Combine(Environment.CurrentDirectory, fileName); var map = new Map(); var content = File.ReadLines(mapPath); var contentInfo = content .Skip(1) .ToArray(); for (var idx = 0; idx < contentInfo.Length; idx++) { var arr = contentInfo[idx] .Split(' ') .Select(int.Parse) .ToArray(); var step = new Step(); foreach (var val in arr) { step.AddTile(new Tile {Elevation = val}); } map.AddStep(step); } return map; }
public IEnumerable<IList<int>> Find(Map map) { var flattenPath = new List<IList<int>>(); var allTiles = new List<Tile>(); foreach (var step in map.Steps) { allTiles.AddRange(step.Tiles); } foreach (var tile in allTiles) { TraverseDownward(flattenPath, tile, new List<int>()); } return flattenPath; }