Skip to content

VincentZ-42/TetrisMap-Fillit-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TetrisMap (Fillit)

  • Program that produces the smallest possible square board that can fit given Tetris pieces. Among all possibilities, Tetris pieces were placed on their most upper-left position.

Screen Shot 2019-12-26 at 4 02 29 PM

Table Of Contents

Objective

  • Learn about string manipulation (string parsing from reading a file) and memory management
  • Learn how to use and traverse a linked list (data structure)
  • Learn how implement recursive backtracking algorithm

Understanding the Program

Input

The input is a file that contains a list of Tetris pieces. Every Tetris piece fits in a 4x4 chars square and all Tetris pieces are separated by a newline each. Each Tetris piece follows the four rules below:

  • Each Tetris piece is precisely 4 lines of 4 characters, each followed by a new line (4x4 square)
  • A Tetris piece is composed of 4 blocks.
  • Each character must be either a block character (#) or an empty character (.)
  • Each block of a Tetris piece must touch at least one other block on any of its 4 sides (up, down, left, and right)

Screen Shot 2019-12-26 at 4 24 10 PM

Output

Screen Shot 2019-12-26 at 4 51 15 PM

The smallest assembled square of Tetris pieces will be produced on the standard output, with letters A - Z representing the order of the Tetris pieces in the list and placed on the board.

  • Because there are only 26 letters in the alphabet, the list of Tetris pieces is limited to 26 when reading the input file.
  • Please refer to the example to the right

Usage

Please ensure you have gcc compiler and that you are using a Unix/Linux terminal

  1. Open Terminal and clone Repository into desired location
  2. Type "make" in the command line to create the executable program called "fillit"
  3. Run the executable by typing "./fillit file" where file is the text file containing the list of Tetris pieces
  • Try typing "./fillit input" in the command line to view the output or create your own input file

Further Thoughts

  • Program can be further optimized by storing each Tetris piece as bits instead of an integer array in our data structure

References

About

Project involving utilizing recursive backtracking to assemble Tetriminos together in the smallest possible square

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors