Hi guys,
Got stuck for this CoderPad screen and I'm not sure how to solve it for when the blocks are not regularly shaped (like L or U or hollow shapes). If you could help that would be amazing! Thank you!
========
You make wooden toys in your woodworking shop for the enjoyment of your grandchildren. You have planned a series of small puzzles, and you would like to automate the writing of their solutions.
RULES:
Each puzzle is a grid, on which wooden blocks are placed. These blocks must be taken out of the game, one after the other, without colliding. You have to determine the order in which they are taken out.
Each block is numbered with a value between 0-9.
When you enter the number of a block, it will be moved to the right until it is off of the grid.
All blocks can be simple one by one sized squares, or more complicated shapes like L-shape, U-shape, or square/rectangles with hollow core.
To find a block to exit, you can select one of the numbers located on the rightmost square of the grid.
If more than one block can be taken out at the same time, you can choose which one you would like to remove first.
The grid is formatted as: a list of height strings, each string having width size. The string can contain one of 3 things: . for empty square, number for a piece of the block occupying the square, or X for wall. You can assume the wall is only covering the leftmost side, top and bottom of the grid - leaving the rightmost side open for exit.
ASK:
Implement the function solve(width, height, nb_blocks, grid). This function is executed at each round of the game and should return the number of the next block to move, or -1 if no movement could be made without collision./