# Sunday Times Teaser 2996 – Piece It Together

### by Victor Bryant

#### Published Sunday February 23 2020 (link)

I have some jigsaw-type pieces each consisting of one, two, three or four 1cm-by-1cm squares joined together without overlapping. The pieces are black on one side and white on the other, and they are all different. I have used all my pieces to simultaneously make some different-sized white squares in jigsaw fashion, with each square using more than one piece. Even if you knew what all my pieces were like, you would not be able to determine the sizes of my squares.

This solution uses a collection of routines that I have put together in jigsaw.py

It uses either specific rectangle fitting code or Donald Knuth’s ‘Algorithm X’ (by changing ‘solve_rect as solve_rect’ to ‘solve_rectx as solve_rect’ in line 2). It produces the solution with the following two sets of squares in under a second.

The illustrations for the 4*4 and 5*5 have two pieces of 4 squares that are the same, Shouldn’t one of the four square pieces be three squares in a row with the fourth attached at the middle?