Robots on ice
Part 1 - The basic
You are helping a robot R
on an iced island. R
can go
up/down/left/right. But since the island is made of ice, it cannot
move only 1 square at a time, but instead moves in straight line. Your
task is to help R
reach G
.
Input
The input (file, stdin, input, whatever suits you) is an n×m
matrice with the following characters:
R
The robot
G
The goal
#
An obstacle that stops the robot
Ice
The island is surrounded by a wall: the edges of the matrice always consist of #
.
Output
A list of instructions consisting of U/D/L/R, corresponding to
up/down/left/right.
The list should be the shortest possible. The distance traveled by the
robot doesn't count.
The output should be the map with the instructions on it, with each
instruction at the right coordinates. Each of RG#
should be
displayed if not overriden by an instruction (that will always be the
case for R
)
Example
Input:
##########
# # #
# #
# G # #
# #
# R# #
# #
##########
Output:
Since D,R,U,L,D is one possible solution, the output should be:
##########
# #D L#
# #
# G # #
# #
# D# #
# R U#
##########
Another solution, U,R,U,L,D, should be output as:
##########
# #D L#
# #
# G # #
# R U#
# U# #
# #
##########
Input:
####################
###R ###
# ###### #
# ##### #
## G#
### ###
####################
Output:
####################
###R D###
#RD###### #
#U L ##### #
##R G#
###U L###
####################
You can assume that the puzzle always has at least 1 solution
Part 2 - New options
The pitch is the same, but new characters can be displayed:
Input
The input (file, stdin, input, whatever suits you) is an n×m
matrice with the following characters:
R
The robot
G
The goal
#
An obstacle that stops the robot
Ice
W
Some water. Robot doesn’t like water
B
a Box. Robot can push the box 1 square at a time, in front of
him (not on the side), if the next square is
. It cannot be
pushed into the water, through the goal… Robot cannot push 2 boxes
at once. When pushing, the robot stays in place.
1
a numbered teleportation door. Always in pair. When entering a
teleportation door, Robot will continue sliding in the same
direction through the other door. Can be used more than 1 time.
The island will this time be surrounded by water.
Output
A list of instructions consisting of U/D/L/R, corresponding to
up/down/left/right.
The list should be the shortest possible. The distance traveled by the
robot doesn't count.
This time the output won't be displayed on the map, but on stdout. The
format doesn't matter:
UDRL
or
U
D
R
L
are accepted
Example
Input:
WWWWWWWWWW
W W W
W W
W G 1 W
W W
W 1R W
W W
WWWWWWWWWW
Output:
L
Input:
WWWWWWWWWW
W W W
W # W
W G W
W W
W BR W
W W
WWWWWWWWWW
Output:
LLUL
The first L moves the box (but not the Robot) 1 square:
WWWWWWWWWW
W W W
W # W
W G W
W W
W B R W
W W
WWWWWWWWWW
Input:
WWWWWWWWWWWWW
W # W
W G 2 W
W W
W B 1 W
W#2 W
W # 1R #W
W #W
W # #W
WWWWWWWWWWWWW
Output:
L #entering teleportation 1
L #pushing the box to the left
L #going to the box
U #entering teleportation 2
The solution RULU
is also valid
Input:
WWWWWWWWWWWWW
W # W
W # W
W# 1 W
W W
W W
W 1 R W
W W
W G W
WWWWWWWWWWWWW
Output:
L #entering teleportation 1
U #going to the wall
R #going to the wall
D #entering teleportation 1
In this situations, Robot cannot moves to the left:
W GBR W
W #BR W
W BBR W
W WBR W
W R W
You can assume that the puzzle always has at least 1 solution
Part 3 - With help
Same as part 2 but with others robots:
Input
The input (file, stdin, input, whatever suits you) is an n×m
matrice with the following characters:
R
The robot
G
The goal
#
An obstacle that stops the robot
Ice
W
Some water. Robot doesn’t like water
B
a Box. Robot can push the box 1 square at a time, in front of
him (not on the side), if the next square is
. It cannot be
pushed into the water, through the goal… Robot cannot push 2 boxes
at once. When pushing, the robot stays in place.
1
a numbered teleportation door. Always in pair. When entering a
teleportation door, Robot will continue sliding in the same
direction through the other door. Can be used more than 1 time.
abcde
up to 5 robots that can move the same as Robot. They cannot
go through other robots, including R, and can pass through the Goal.
They can be sacrified by going into the water. They can be used more
than 1 time.
The island is surrounded by water.
Output
A list of instructions consisting of U/D/L/R, corresponding to
up/down/left/right, prefixed by the name of the robot moving.
The list should be the shortest possible. The distance traveled by the
robot doesn't count.
As usual, theformat doesn't matter:
a:UDR
R:LU
or
aU
aD
aR
RL
RU
are accepted
Example
Input:
WWWWWWWWWWWWWWWWWW
W a # W
W G W
W W
W W
W W
W R W
W W
W # W
W # W
W W
WWWWWWWWWWWWWWWWWW
Output:
a:R
R:UL
The answer DLUL
is valid but not the shortest
Input:
WWWWWWWWWWWWWWWWWW
W W
W W
W W
W W
W G a R W
W W
W W
W W
W W
W W
WWWWWWWWWWWWWWWWWW
Output:
a:U
R:L
Input:
WWWWWWWWWWWWWWWWWW
W # W
W W
W # W
W G W
W W
W W
W b W
W R a W
W W
W W
WWWWWWWWWWWWWWWWWW
Output:
b:U
a:UL
R:UR
Input:
WWWWWWWWWWWWWWWWWW
W W
W # W
W B W
W # W
W G W
W W
W # W
W e R# W
W W
W a W
WWWWWWWWWWWWWWWWWW
Output:
e:R
R:U
a:UL
R:LLDLUR
Input:
WWWWWWWWWWWWWWWWWW
W W
W G # W
W b W
W W
W a W
W c W
W # W
W R W
W W
W # W
WWWWWWWWWWWWWWWWWW
Output:
a:U
b:RD
a:D
C:RD
R:RU
Input:
WWWWWWWWWW
W G W
W aBbBR W
WWWWWWWWWW
Output:
a:L
b:LL
R:LLU
In this situations, R
obot and b
cannot move to the left:
W GaRb W
W #b#R W
W aBbBR W
You can assume that the puzzle always has at least 1 solution
Sandbox Questions
Has it been done before?
What do you think? Is it understandable? Should I do 3 separated
challenges (and in the sandbox)? More, less? Which part needs more examples? What part is
unclear?
I would like to go with shortest-code win. Should I use kolmogorov instead?