Skip to content

Instantly share code, notes, and snippets.

@visualmotive
Last active August 29, 2015 13:58
Show Gist options
  • Save visualmotive/10223114 to your computer and use it in GitHub Desktop.
Save visualmotive/10223114 to your computer and use it in GitHub Desktop.
Tetris with Sticky Gravity - Thumbtack PyCon Programming Challenge 2014

Sticky gravity is explained in depth here: http://tetrisconcept.net/wiki/Line_clear#Sticky

The playfield is divided into connected segments using flood fill. Any blocks that are adjacent horizontally or vertically are marked as one segment, that is, they are treated as having "stuck" together. Each segment falls independently until it meets the floor or another block. Additional line clears may result.

Sample input and expected output are included in this Gist.

..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
....XX....
....X.....
....X.....
..........
XXXX..XXXX
XXXX.XXXXX
X........X
X........X
XXXX.XXXXX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment