It’s exciting time! Now let’s consider the most famous video game in the world: Tetris.
Tetris is a puzzle video game originally designed and programmed by Alexey Pajitnov. It was created on June 6, 1984. The game is available for nearly every video game console and computer operating system, as well as devices such as graphing calculators, mobile phones, portable media players, PDAs and even as an Easter egg on non-media products like oscilloscopes.
Some random tetrominoes (shapes each composed of four square blocks) will fall down sequentially into the playing field. The objective of the game is to manipulate those tetrominoes, by moving each one sideways and/or rotating it, with the aim of creating a horizontal line of blocks without gaps. When such a line is created, it disappears, and any block above that line will fall until it hits an obstacle. See the sample test case for further details.
Tetris game manuals refer to the seven one-side tetrominoes in Tetris as I, J, L, O, S, T and Z (due to their resembling letters of the alphabet). All are capable of single and double clears. I, J and L are able to clear triples. Only the I tetromino has the capacity to clear four lines simultaneously, and this is referred to as a “tetris”.
Wikipedia (http://en.wikipedia.org/wiki/Tetris)
The scoring formula for the majority of Tetris products is based on the idea that more difficult line clears should be awarded more points. Specifically, a single clear will be awarded 100 points, 250 points for a double clear, 400 points for a triple clear, and 1000 points for a “tetris”.
Now you are given the width of the playing field and a sequence of tetrominoes with the position and degrees it rotated. The task is to calculate how many points will be awarded.
You can assume the playing field is high enough, so that tetrominoes will not overlap each other even when a tetromino is created at the top of the playing field.