Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Drawing polyominoes

How can I write a function which takes a list of coordinates and draws the corresponding polyomino? To draw something like a rectangle I wrote the following:

def drawRectangle(A,B): return polygon([(A[0], A[1]), (A[0], B[1]), (B[0], B[1]), (B[0], A[1])])

But imagine if we have a bigger figure, how can I do this without using polygon? So how can I write a function which takes a list of coordinates and draws its polyomino? For example [(0,0), (0,1), (1,1), (1,2)] is equivalent with a tetromino.