Objective
Create a Python program that finds a path from the entrance to the exit of a maze with backtracking. The path you find depends on the order in which you try the directions, so it is fixed.
Instructions
- Read an integer
n(1 to 8) and thennrows of text, all of the same length:Sis the entrance (there is one),Ethe exit (there is one),.a free path and#a wall. - Write a recursive function that, from a cell, returns the text with the moves to the exit, or
Noneif there is no path. Mark each cell as visited on entering (and do not unmark it). - Always try the directions in this order:
D(down),R(right),U(up),L(left). Return the move's letter followed by the rest of the path. - Show
Path: DDRRandLength: 4, orNo path.
3
S.#
.#.
..E
Path: DDRR
Length: 4
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise