forked from jshap23/shortestPathD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q5_text.txt
executable file
·16 lines (12 loc) · 1.06 KB
/
q5_text.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
5.
The Prince of Persia has been thrown onto the top level of Jaffar's underground labyrinth. The labyrinth consists of h levels strictly on top of each other. Each level is split into m by n areas. Some areas have columns that support ceiling, some areas are free. The Prince can move only to free areas. To move to the level below the Prince can break the floor underneath him and jump down if there is no column underneath. Every move takes the Prince 5 seconds. A Princess is waiting for the Prince at the lowest level. Write a program that will help the Prince to save the Princess as fast as possible by finding the shortest path between them and outputting time it took the Prince to find the Princess. The structure of the labyrinth is given bellow. The Prince’s location is marked with '1', the Princess’s location is marked with '2'. ‘.’ - marks a free spot and ‘o’ marks a column.
1 . .
o o .
. . .
o o o
. . o
. o o
o o o
o . .
o . 2
PS. Because good always trumps evil - you can assume that there is always a way for Prince to find his Princess.