a program to fill the smallest square with given tetrominos (using Knuth's Algorithm X)
This project calcultates the smallest square which can be filled with given tetrominos. It uses the Knuth‘s Algorithm X and the Dancing Links optimization.
You will need to download the libs
project in the same directory you will clone fillit
to run it!
do make
in the directory fillit
fillit file
where file
is a mandatory argument that represents the list of tetrominos you want to pack in the smallest possible square.
The input file is a text file. Each tetromino is written in 4 lines and 4 columns where .
represents a blank and #
represents a block of a the tetromino. Theremust be an empty line between each tetromino.
The 7 basic tetrominos are available :
####
.#..
....
.#..
....
.#..
....
.#..
....
....
..##
..##
.#..
....
.#..
....
###.
#...
##..
....
....
##..
.#..
###.
....
#...
....
.#..
....
....
.#..
.###
##..
....
.#..
...#
#...
#...
##..
....
#...
###.
....
....
....
...#
.#..
....
.##.
.###
.#..
....
..#.
....
.##.
###.
..#.
....
....
#...
....
..#.
.##.
..##
##..
...#
....
....
.##.
....
..##
..#.
....
.##.
....
.#..
No matter where the tetromino is placed in the 4x4-blocks area, the program considers it as the same piece.
For example :
....
##..
....
..##
.##.
.#..
##..
...#
..#.
.#..
.#..
...#
..#.
....
.#..
....
are seen as the same piece
The file must contains 26 tetrominos at most!
The program displays the smallest square filled with the given tetrominos.
A
B
C
D
examples will be provided later