13

5

## Introduction

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.

## Challenge

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.

## Criteria

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

## Input

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.

## Output

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
I L J
I OO L J T ZZ SS
I OO LL JJ TTT ZZ SS
```

## Example

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
```

## Notes

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.

## Scoring

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

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.

– Martin Ender – 2015-03-07T02:58:59.353Thatis 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.@MartinBüttner Duly noted, thanks for the feedback. – CzarMatt – 2015-03-07T05:04:27.177

2Ides of March = 15 of March. I had to look that up. – Level River St – 2015-03-07T08:12:52.133

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. – Peter Taylor – 2015-03-08T15:07:27.347

@PeterTaylor Fair enough, I've added which solution set cannot be solved. Thanks for the feedback. – CzarMatt – 2015-03-09T15:56:15.477

Are there any standard algorithms for solving this kind of problem? – Jonah – 2018-11-13T04:02:02.443