Introduction
A family of seals are stranded upon an iceberg in the Arctic Circle. There is a radio transmitter located on the iceberg which the seals can use to call for help. However, only the daddy seal knows how to operate the radio transmitter. And worse, the ice is very slippery this time of year, so the seals will slide uncontrollably until they hit another seal or slide off the edge of the iceberg, making it very difficult for the daddy seal to reach the radio transmitter. Luckily, one of the seals is a computer scientist, so she decides to write a program to figure out how to manoeuvre the daddy seal to the radio transmitter. As there is not much space on the ice to write a program, she decides to make the program use as little bytes as possible.
Input Description
The seal's program will take input in from STDIN, command line arguments, or user input functions (such as raw_input()
). It cannot be preinitialised in a variable (e.g. "This program expects the input in a variable x
").
The first line of the input consists of two comma separated integers in the form
A,B
Following that is B
lines consisting of A
characters each. Each line can only contain characters out of the following:
.
: The cold, cold, ocean. The map will always have this as a border.#
: A part of the iceberg.a
...z
: A seal that is not the daddy seal on the iceberg.D
: The daddy seal on the iceberg.*
: The radio transmitter.
(Note that the daddy seal is always notated with an uppercase D
. A lowercase d
is simply a regular seal.)
Output Description
According to the following rules regarding how the seals can move, output a list of instructions for the seals on how they should move to get the daddy seal to the radio transmitter.
- Rule: All seals can move up (
U
), down (D
), left (L
), and right (R
). They cannot slide diagonally. - Rule: Upon moving, a seal will continue to move in the same direction until it collides with another seal or falls into the sea.
- If a seal collides with another seal, it will stop moving. The seal it collided with will not move.
- If a seal falls into the sea, it will drown and disappear from the map. That is, it does not act as a collider for other seals and it cannot be moved again.
- Rule: Two seals cannot move at the same time, neither can a seal be moved while another one is still moving. The next seal can only be moved once the previous seal has stopped moving.
- Rule: There is no restriction regarding moving a seal multiple times, or the number of seals that drown.
- Rule: A correct solution will have the daddy seal end at the radio transmitter. The daddy seal cannot simply pass the transmitter while sliding.
The output will consist of several lines, each in the form
A,B
Where A
is the seal to move (D
for the daddy seal, a
...z
for others), and B
is the direction to move the seal (either U
, D
, L
, or R
). Note that you do not need to find the shortest route. Any route that gets the daddy seal to the goal is an acceptable output.
Example Inputs and Outputs
Input:
25,5
.........................
.#######################.
.####D#############*k###.
.#######################.
.........................
Output:
D,R
Input:
9,7
.........
.a#####b.
.#####d#.
.##l*###.
.###m#p#.
.#D#.#c#.
.........
Output (one possible output out of many):
m,R
b,L
D,U
D,R
D,D
D,L
Input:
26,5
..........................
.###..................###.
.l*##########v#########D#.
.###..................###.
..........................
Output (one possible output out of many):
v,D
D,L
If you have any other questions, please ask in the comments.