Challenge Taken from my university code challenge contest
This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here.
Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a board, so that they fit in the most compact way possible.
In this problem we will assume a sequence of pieces that fall, each in a certain position and with a certain orientation that can not be changed. The pieces are piled up as they fall and the complete rows are not eliminated (as in the original game). The objective is to determine the final height of each column of the board after all the pieces fall.
There are a total of 7 different pieces, shown in the figure:
Given a list of pieces, output the height of all the columns from the board after all pieces falls
A piece consists of three numbers: I, R and P. The first number, I, is the identifier of the piece (a number between 1 and 7, in the same order as in the figure). The second number, R, is the rotation of the piece. It can take the values 0, 90, 180 or 270 and represents the angle of rotation of the piece in the anti-clockwise direction. The third number, P, indicates the position of the piece. Represents the column on the left occupied by the piece (this can be 1 or 0 Index. Please specify).
Example and Test case (1 Index)
[[1, 0, 1], [4, 0, 1], [5, 90, 4]]
[3, 3, 1, 3, 2]
[[6, 270, 4], [1, 180, 5], [1, 90, 6], [7, 0, 4]]
[0, 0, 0, 9, 9, 8, 3, 3]
- This is code-golf
- Row/Column can be 1 or 0 Index. Please specify.
- You can redefine input values (maybe you want to call piece 1 as A, etc..). In that case please specify
Can we use any 4 distinct values instead of an angle in degrees?: Yes
Are we supposed to handle "holes" if a piece doesn't exactly fit over the previous ones?: Yes
Is the height or the width of the board bounded? No. Neither the width nor the height are bounded
Thanks @Arnauld for the images and the test cases *.*