Sokoban re-solver : level recovery from solution
Description:
I suggest you write a program that, having a string containing the solution of the level for the game Sokoban, will restore the original level.
The rules of the Sokoban:
The objective of the Sokoban game is to move objects (usually boxes) to designated locations by pushing them. These objects are located inside a room surrounded by walls. The user controls a pusher called "Sokoban" which is said to mean something like "warehouse keeper" in Japanese. The pusher can move up, down, left and right, but cannot pass through walls or boxes, and can only push one box at a time (never pull). At any time, a square can only be occupied by either a wall, a box, or the pusher.

You can read more about this game here:
https://en.wikipedia.org/wiki/Sokoban
http://www.sokobano.de/wiki/index.php?title=Main_Page
you can play in this game:
https://sourceforge.net/projects/sokobanyasc/
https://sokoban.info/
TASK:
as input, your function will receive a string containing the solution of the level. notation format "LURD"
the characters "lurd" (lowercase) indicate the movement of the player to the left, up, right, down.
the symbols "LURD" (in uppercase) indicate that the player pushes the box left, up, right, down.
(letters in uppercase imply that the player is sure to push the box)
solution = "urrrrDrdddldlluuurRlldddrruruUluullllddddRluuuurrrrddrddldllUdrruruulllLrrruulllldDrrrrrddldlluUddrruruuluullllddrRRldddrruruuruLdddldlluuurUdldddrruruuuLuLLLrrrdrdddldlluuurUruLLrddRlldddrruruUruLLdlUruL"
at the output, your function should return the drawn level inside the text string.
there must be no spaces at the end of substrings, and there must be an end-of-line character "\n"
map = """
#######
#... ###
#@##$$ #
# $ #
#.# ## ##
# $ # #
### ##
#####
"""
description of the level format you can find here:
http://www.sokobano.de/wiki/index.php?title=Level_format
Wall - "#", Player - "@", Player on goal - "+", Box - "$", Box on goal - "*", Goal - ".", Floor - " " (Space)
when creating a level map, you should add a minimum of elements, only what is necessary. you can not add extra walls and boxes with which the player does not interact.
Minimal amount of free space inside the outer bound. Minimal amount of boxes. Outer bound must be of thickness of 1, connected orthogonally and minimal. The level must be drawn with no extra spaces on either side.
Technical Details
- Input will always be valid solution for real level.
- level size < 50*50
- you need find solution for 35 hand-made levels, +90 random-generated levels
Similar Kata:
Stats:
Created | Sep 8, 2022 |
Published | Sep 8, 2022 |
Warriors Trained | 176 |
Total Skips | 7 |
Total Code Submissions | 215 |
Total Times Completed | 31 |
Python Completions | 31 |
Total Stars | 13 |
% of votes with a positive feedback rating | 97% of 15 |
Total "Very Satisfied" Votes | 14 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 5 kyu |