Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:
S
: The location on the maze you start atE
: The location you are trying to get to0
: Wall that you can't cross+
: Floor that you can cross
You can travel in one of six directions: up-left, up-right, left, right, down-left, or down-right.
\ /
-S-
/ \
The maze does not wrap. The goal is to find the shortest path string to get from S
to E
.
Input:
Input is space separated lines like the mazes shown. No trailing space will follow a line.
Output:
A string of R
, L
, and F
where
R
rotates you right (clockwise) 60 degreesL
rotates you left (counter clockwise) 60 degreesF
moves you one space in the direction you are pointing
You start pointing left-up
The shortest path is counted by the length of the string produced, not the number of positions visited. Your program must print the shortest path as the solution.
If the maze is unsolvable you should output Invalid maze!
.
(>>>
is the output)
0 0 0 0
0 + 0 + 0
0 0 0 + + 0
0 + 0 + 0 + 0
0 0 + + 0 0 + 0
0 0 + 0 + 0 0 + 0
E 0 + 0 0 + + 0
+ + 0 + 0 + 0
0 0 0 0 0 +
+ 0 + + +
0 S 0 0
>>>RFRFFLFLFRFFLFFFLFLFFRFLFLFRFRFRF
+ 0 0 0 0 0 0
0 0 0 0 0 + + 0
0 0 E 0 + 0 0 + 0
0 0 0 0 0 0 0 +
0 + 0 0 + + +
0 0 + + 0 0
S + 0 0 0
>>>Invalid maze!
0 E S
>>>LF
E + 0
0 + + +
0 0 S
+ +
>>>FFLF
E
0 +
0 + +
0 +
S
>>>RFFLFF
0 E + 0 0
0 + 0 0 + +
+ 0 + + + 0
+ 0 + 0 + 0
+ + + 0 S
>>>FFLFLFFRFRFFRFF
E 0 + + 0
0 + 0 + + 0
+ + + 0 + 0
+ 0 0 0 0 0
+ + + + 0
+ 0 S 0
>>>FLFFRFFRFLF
(Note that some of the mazes have other solutions that are the same length but are not listed here)