Tangrams are a classic puzzle involving arranging/fitting blocks into various shapes. From the Chinese 七巧板 - literally meaning "seven boards of skill". Let's take this idea and use the seven Tetrominos pieces to fill a grid.
Write a function or program that takes an array of grid coordinates as input, and outputs a completed 10 by 20 grid filled with Tetris pieces except in the specified coordinates.
Optimize your score by attempting to keep the distribution of pieces uniform.
Use this pastebin of coordinates to accomplish your task. There are five sets of coordinates. Feel free to modify the format in which the coordinates are written, but not the values.
Data set #2 cannot be solved - in this case, simply output the grid with input cells filled in (i.e.,
X's where the holes are).
Grid coordinates represent 'holes' in the grid. These are cells which cannot contain any part of a Tetromino.
(0,0), (1,0), (2,0), ... (9,0) (0,1), (1,1), (2,1), ... (9,1) . . . (0,19), (1,19), (2,19), ... (9,19)
Use your programming language's array style of choice to input the coordinates.
Represent holes in the grid with an
Xor other printable ASCII.
Using a standard Tetris grid size of 10 cells wide by 20 cells tall, print a solution grid if and only if the grid can be filled completely and perfectly using Tetromino pieces.
Pieces constructed with letters
S as follows:
I I L J I OO L J T ZZ SS I OO LL JJ TTT ZZ SS
Output solution example with no input coordinates:
ZZIIIILLLI JZZTTTLLLI JJJSTLOOLI SZZSSLOOLI SSZZSLLJJI TSOOSLLJII TTOOSSLJII TZOOSSLZII ZZOOSSZZII ZJJJJSZLLI TTTJJOOILI ITZJJOOILI IZZTTTLIII IZOOTZLIII IJOOZZLLII LJJJZSSTII LLLTSSTTTI LLLTTSSZJI OOLTSSZZJI OOIIIIZJJI
With distribution as follows:
I I L J I OO L J T ZZ SS I OO LL JJ TTT ZZ SS 11 6 8 6 6 7 6
Coordinates represent a single
Y position on the grid. The grid is 0 based, meaning coordinate
(0,0) should either be the top left or the bottom left cell, author's choice.
- be selected at author's discretion.
- be rotated as author sees fit.
- be placed on the grid anywhere at author's discretion (aka: no Tetris gravity)
- be placed outside the bounds of the grid.
- overlap an existing brick or hole in the grid.
- be a non-standard Tetris tetromino piece.
Your score is in the format:
( 1000 - [bytes in code] ) * ( M / 10 + 1 )
Where M is a multiplier for the distribution of pieces used in your solution sets.
Highest score by the Ides of March wins.
To calculate M, add the lowest individual tetromino distribution value for each set and then take the average rounded down to calculate M.
Set 1: 5 Set 2: 4 Set 3: 5 Set 4: 6 Set 5: 3
6 + 4 + 5 + 4 + 4 = 21 / 5 = 4.6
So you would use
4 as your M value.
Note: If a set has no solution, do not factor that set into calculating M, since it would have no tetromino distribution.