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.

Grid coordinates:

(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 X or 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 I, O, L, J, T, Z, S as follows:

I          L      J
I    OO    L      J     T     ZZ      SS
I    OO    LL    JJ    TTT     ZZ    SS


Output solution example with no input coordinates:


With distribution as follows:

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 X and 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.

Bricks can:

  • 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)

Bricks cannot:

  • 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.

For example:

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.

  • 4
    \$\begingroup\$ Improving questions after they are posted is generally difficult, because if the changes are substantial they will invalidate work of people who have already started working on the problem (or worse, even posted the result). I would recommend posting challenge ideas in the sandbox. That is the place to ask for feedback and polish the spec before it goes on main. That being said, after a quick skim, I didn't see any glaring problems with your challenge. \$\endgroup\$ – Martin Ender Mar 7 '15 at 2:58
  • \$\begingroup\$ @MartinBüttner Duly noted, thanks for the feedback. \$\endgroup\$ – CzarMatt Mar 7 '15 at 5:04
  • 2
    \$\begingroup\$ Ides of March = 15 of March. I had to look that up. \$\endgroup\$ – Level River St Mar 7 '15 at 8:12
  • \$\begingroup\$ I've made some small changes to front-load the task description, because otherwise it's impossible to understand what we're being asked to do on the first read-through. I think it would be an improvement if you stated which of the input cases can't be solved, so that they function as test cases in addition to a scoring dataset. \$\endgroup\$ – Peter Taylor Mar 8 '15 at 15:07
  • \$\begingroup\$ @PeterTaylor Fair enough, I've added which solution set cannot be solved. Thanks for the feedback. \$\endgroup\$ – CzarMatt Mar 9 '15 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.