How to solve this simple looking hard problem?

Bluto has Olive! Popeye must navigate the puzzle, defeat Bluto first and then rescue the Olive while avoiding any hazards.

Input format:
The first line will contain an integer N (3<= N<= 100) that denotes the size of the matrix. Followed by an NxN grid. The Olive will be shown as a 'o', Bluto will be shown as a 'b', the popeye will be shown as an 'p'. '@' spaces are hazards and '^' spaces are clear to move into.

Output format:
The moves can be printed out to standard out and human readable, however you want to represent them. There are 4 valid moves, LEFT, RIGHT, UP, and DOWN

Task:
The input will come from Stdin(this will require reading in N+1 lines from Stdin), and the output should be print to Stdout. Use OOP with Java 8 to defeat Bluto and rescue the Olive in the fewest number of moves.

Sample Input:
7
^^^^^o^
^@@@@@@^
^^b^^^^
@@^^^^^
^^^^^^^
^@@@@@@@
^^p^^^^

Sample Output:
LEFT, LEFT, UP, UP, RIGHT, RIGHT, UP, UP, RIGHT, RIGHT, RIGHT, RIGHT, UP, UP, LEFT

Comments (1)