402186: GYM100687 L Snake (B)
Description
Dr. Rawan’s students found the warmup exercise to be very easy and asked for a more challenging task. Therefore, Dr. Rawan asked them to write a program that will help the snake reach the exit door.
Given the state of a snake on the 16x32 grid as described before, your task is to find any sequence of moves (using the symbols >, <, ^ and v) that will allow the snake to reach the exit cell. The sequence of moves should not make the snake intersect itself.
InputEach line of the first 16 lines of input contains 32 characters, which represent the state of the snake on the grid.
The number of dots that are not reachable from the borders doesn't exceed 32, and all characters on the border are dots.
The length of the snake doesn't exceed 75 cells.
OutputPrint a sequence of moves that will make the snake reach the exit cell without intersecting itself. The sequence should contain at most 1024 characters.
If no sequence exists, print '—' (3 dashes) without the single quotes.
ExamplesInput................................Output
................................
................................
................................
................................
................................
..........>v.:<<<...............
........E..v....^...............
...........v....^...............
...........>>>>>^...............
................................
................................
................................
................................
................................
................................
^<<<<vv<