Programming Assignment 3 - Divide and Conquer

Due: October 24th at 5pm.

Tiling with Trominos

Solve the following problem: tile a chessboard of size 2^n x 2^n with one square missing with L-shaped trominos. Here's how a tromino looks like:

And here's an example of a solution for an 8x8 board:

There is a simple proof by induction that this is possible. This proof can be easily translated into a divide and conquer algorithm for solving the problem. There is a nice tromino applet that can help you.

Correctness of your program will be verified visually: you need to produce a visualization of the tiling produced by your program. We suggest one of two options for producing the image - matplotlib, which is a plotting library for python, and tkinter, which is the standard Python GUI package. With matplotlib, you may find the polygon command useful (here are some examples). If you decide to use tkinter, here are some starting points: Canvas tutorial, and another one.

Submit your code as a single python program called HW3.py, which will be executed as:

python HW3.py 3

for an 8x8 board.

Comments:

  • Running your program should bring up a window with the visualization of the tiling.
  • Your program should randomly choose the position in the board that is supposed to be blank. Use Python's random module for that.
  • To retrieve command-line arguments inside a python program import the sys module, and use the sys.argv variable. See details here.

Note:

A solution which does not follow the inductive proof, will not be accepted.