5 kyu

Navigating a Maze

Description:

Your task is to find the path between two points inside a square maze. The mazes are generated using Eller's algorithm, so there is only one possible path between any two points. Mazes look like this:

#######
# #   #
# # ###      S - start point
#    G#      G - goal point
### # #      # - walls of the maze
#S  # #
#######

Implement the FindPath method, which returns an array of traversed indices to reach the goal point from the start point.

Available input data:

maze - flat 1D array where True shows a passable space and False means a wall
size - length of one side of the maze including borders (maze is square)
startIndex - the index of the cell in the maze array to start your path from
goalIndex - the index of the cell in the maze array to reach

In the maze above S has index 36 and G has index 26 in the maze array, so the correct path would be through these cells:

{ 36, 37, 38, 31, 24, 25, 26 }

There are some static tests and some random tests with mazes of different sizes.

Algorithms
Graph Theory

Similar Kata:

Stats:

CreatedFeb 26, 2016
PublishedFeb 26, 2016
Warriors Trained553
Total Skips148
Total Code Submissions325
Total Times Completed86
C# Completions86
Total Stars32
% of votes with a positive feedback rating92% of 38
Total "Very Satisfied" Votes34
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes2
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • alekseil Avatar
  • smile67 Avatar
  • hobovsky Avatar
Ad