Ogmo is a wizard that has been imprisoned in a dungeon. He needs your help.
Create a function that takes the map of a dungeon as an argument and prints a new map that indicates the shortest path to escape from the dungeon, as well as the minimum number of steps to reach the exit and the escape sequence.
O.X. There will always be an exit from the dungeon and the exit can be anywhere inside the dungeon (not only in the borders of the map).R, Left L, Up U, Down D.+.#. Ogmo can only move through the empty spaces " ".escape([
["#", "#", "#", "#", "#"],
["#", "O", " ", " ", "#"],
["#", "#", " ", "#", "#"],
["#", " ", " ", " ", "X"],
["#", "#", "#", "#", "#"]
]) ➞
["#", "#", "#", "#", "#"]
["#", "O", "+", " ", "#"]
["#", "#", "+", "#", "#"]
["#", " ", "+", "+", "+"]
["#", "#", "#", "#", "#"]
# Number of steps to escape from the dungeon: 5
# Escape sequence: RDDRR
escape([
["#", "#", "#", "#", "#"],
["#", "O", " ", "X", "#"],
["#", "#", " ", "#", "#"],
["#", " ", " ", " ", "#"],
["#", "#", "#", "#", "#"]
]) ➞
["#", "#", "#", "#", "#"]
["#", "O", "+", "+", "#"]
["#", "#", " ", "#", "#"]
["#", " ", " ", " ", "#"]
["#", "#", "#", "#", "#"]
# Number of steps to escape from the dungeon: 2
# Escape sequence: RR
Check out the second part of this challenge: Escape the Dungeon II