Sokoban (倉庫番, Sōko-ban, “warehouse keeper”) is a puzzle video game genre in which the player pushes crates or boxes around in a warehouse, trying to get them to storage locations.
- From Wikipedia, the free encyclopedia.
Your goal is to find the actions required to solve the problem.
The possible tiles are listed as follows:
'o': The player stepping on a regular tile
'O': The player stepping on a target tile
'x': A box on a regular tile
'X': A box on a target tile
' ': Nothing on a regular tile
'.': Nothing on a target tile
'#': Wall
Your program should output a sequence of actions that push all the boxes to the target tiles, where the actions are represented by the uppercase WASD
characters:
W
: move the player upA
: move the player leftS
: move the player downD
: move the player right
Example 1:
Input:
1
4 9
#########
# xox..#
# #####
#########
Output:
DDAAASAAWDDDD
The first line contains a single integer T (1 ≤ T ≤ 100). Then T test cases follow.
For each test case:
For each test, output a sequence of actions, represented by the uppercase WASD
characters, that push all the boxes to the target tiles. Remember to add a '\n' at the end.