You are an evil wizard, doing evil wizard business, when suddenly your crystal ball alerts you of a hero on their way to defeat you. To crush their hopes and dreams, you decide to trap the hero in a maze. You could just make a big maze but where would be the fun in that? Instead, you decide you want to make the maze as small as possible for a truly humiliating defeat. Thanks to your wizard skills, you know in advance how the hero will navigate the maze.
The hero's moves are represented by a list where each element can be one of "LR", "LS", "RL", "RS", "SL" or "SR". Inside the maze the hero moves forwards until they reach an intersection. Then the corresponding element in the list tells which direction the hero should continue. The hero first tries to move in the direction represented by the first letter, and next in the direction represented by the second letter. So for example, if the hero's moves are ["LS", "SR", "RS"]
, at the first intersection the hero will turn left. If that is not possible, they will go straight. Similarly in the second intersection, the hero will try to go straight, but if that's not possible, they will go right instead.
If the hero reaches a dead end or the beginning of the maze, they will just turn around. If there is a corner (the path just turns), then the hero will just follow the path. These interactions don't require any decisions, and therefore don't consume the decision list.
The hero gives up when they reach an intersection, but the decision list is consumed.
Rules
You are given the hero's move list as input and you have to output the maze as output. The maze begins at the upper left corner and ends at the lower right corner. The maze must be possible to traverse. You can use different values for "LR", etc, but please don't encode any extra information in the values, such as code. Output the maze as ascii art like this:
█ ████████
█ █ █
██ █ █ ███
██ ███ █
█ █ █
████████ █
You can also use different (distinct) characters for the wall and air. You can also return a two dimensional or flattened two dimensional list with two distinct values for wall and air (if you use a flattened list, please also return at least one of the dimensions to remove ambiguity). Since the outer border of a maze is always the same, you can return just the inner portion (also applies to ascii art output).
The maze cannot contain any areas accessible to the hero where the hallway is wider than one block. So for example:
Not Ok:
█ ███
█ █
█ █
███ █
Ok:
█ █
█ ████
█ █
████ █
The size of a maze is the area of it's rectangle bounding box. For example, the preceding maze has size 24.
You must output the smallest maze, where the hero gives up. In case of ties, any minimal solution is fine.
The input list has at least one element.
Test cases
["LR"]
->
█ ██
█ █
██ █
█ █
██ █
or
█ ██
█ █
█ ██
█ █
██ █
or
█ ███
█ █ █
█ █
███ █
["RL","RL","RS","LS","LR","RS","RS","SR","LR","RL"]
->
█ ███
█ ██
█ █ █
█ █
███ █
["LS", "LS", "LS", "LS", "LS", "LS", "LS", "LS", "LS", "LS", "LS", "LS"]
->
█ █████
█ ██
█ █ █ █
█ █ █
█ █ █ █
█ █
█████ █
["LR","RL","LS","LR","LS","LR","SR","SR","LR","SL","RL","SL","RS","RL","SR","LS","RS","SR","LS","SL","RS","SL","SR","SR","RS","RS","RS","RS","RL","LS","RS","RL","RL","SR","RL","RS","SL","RS","LS","RS","SR","SR","SR","RL","RL","SL","LR","LR","RS","RL","SR","SL","SR","RS","SR","RS","RS","RL","RL","RS"]
->
█ █████
█ █ █
█ █ █
█ █ █
█ ██ █
█████ █
["LR","RS","LR","RS","SR","RS","RS","LR","RS","SR","SR","SL","RS","LS","SR","SR","RL","RS","LS","LR","RS","RL","RL","RL","SL","SL","RL","RS","RS","RS","SL","SL","SR","RS","RS","LR","RS","RL","LR","RL","RS","SL","LR","RL","LR","SR","RS","LR","LR","RL","RS","SR","SR","LR","SR","SR","SL","RL","RS","LR","RS","RS","RS","LS","LS","RL","RL","SL","LS","LS","SL","RS","LS","RS","SL","LS","LS","RS","LS","LS","SL","SR","LS","RL","SL","LR","RS","RS","RS","RS","SL","LR","RL","RL","RS","SL","SR","RS","LR","RS","RS","LS","RS","LR","RS","SL","RS","LS","RS","SR","RL","RL","RL","LS","RS","RS","RS","LS","LS","SR"]
->
█ ████
█ █
█ █ ██
█ █
██ ███
█ █
██ █ █
████ █
'RL'
\$\endgroup\$