Puzzles/Logic puzzles/Niki the Robot

Puzzles | Logic puzzles | Niki the Robot

Niki, the robot, lives on a chessboard with 8 by 8 squares. At any time Niki has a defined orientation looking either west (<), north (^), east (>) or south (v) and uniquely lives on one of the squares. Niki can be programmed by a sequence of the following commands:

move'n'pick Moves one square in the current direction and picks up an item, if present. Items are denoted with '*' on the board.

turn right Changes the direction of niki clockwise.

goto LABEL if wall LABEL can designate the position of any of the commands listed before this one in the program, i.e. the branch can only be upwards in the program. The command branches there if right ahead of Niki there is a wall, which means the border of the board or a wall between squares denoted with 'W'. Otherwise the next command is being executed.

If Niki moves and a wall is ahead, nothing happens.

Problem 1
Niki looks east.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The task is to pick up all items on the board.
 * Find a solution at all.
 * What is the smallest program (in terms of number of instructions) to perform the task?
 * What is the fastest program (in terms of the number of instructions that are executed)?