Expand description
ยงWarehouse Woes
Festive version of Sokoban.
Part one loops in a straight line looking for the next space . or wall #. No bounds checks
are needed as the maze is enclosed. If a space is found then all items are pushed one block
in that direction.
Part two re-uses the part one logic for horizontal moves. Vertical moves use a
breadth-first search to identify the
cascading boxes that need to be moved. Boxes are added strictly left to right to make checking
for previously added boxes easier. To prevent adding a box twice we check that the
item at index - 2 is different. For example:
@ Indices:
[] 23
[][] 4567
[] 89When processing 6 we try to add 8, however 8 and 9 have already been added when processing 4 so we skip.
If any next space is a wall then we cancel the entire move and return right away. Otherwise all boxes are moved in the reverse order that they were found by the search.
Functionsยง
Type Aliasesยง
- Input ๐