First, the program reads each tetromino from its given file, and during the reading, process checking is it a valid piece or not.
If it's not, then the program outputting error
.
After the valid piece gets its shape and with all the data transforming each piece to alphabetical characters and recursive backtracking way solving the task;
to get the smallest square from it. (Place the pieces that between them are not at all/or just a small gap in the shortest amount of time.)
(You can find comments as well with small explanations in the codes.)
The reader.c file:
• Checking for '#' connections and counting them (must be 6 or 8)
• Checking is it a valid character ('.' and/or '#')
• Checking is end of line '\n'
• Checking the lines length
The encode.c file:
• Bitwise mode shifting the bits to their shape
• Measuring each individual tetrominoes width and height
• Adding these data to the final function what we call in reader functions
The solve.c file:
• Using recursive backtracking to check all possibilities for each tetromino and get place them on the map
• For optimization purposes important that the solving part don't do unnecessary computing except what it's made for
The printer.c file:
• Adding to the board with shifting bitwise operators the tetrominoes
• Allocating for the board memory and printing them out
Maximum valid grids: 26
According to the English alphabet.
To execute in default the program, just enter:
make
After compiling type:
./fillit <valid_file.fillit>
You can also use the time
argument to check how fast solving the algorithm the task:
time ./fillit <valid_file.fillit>
If you want to get the result in a colourful version just enter:
make color
To remove it:
make fclean_color
The purpose of this was, to see better each tetromino, and to be accepted by the 42 school project checker AI, had to modify the Makefile and split into two-part, so by default the result will be black and white, but available the colourful version as well.