## Teaser 2996: Piece it together

**From The Sunday Times, 23rd February 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.

How many pieces do I have?

[teaser2996]

## Jim Randell 8:55 pm

on21 February 2020 Permalink |(See also:

Enigma 321).There are only a limited number of 1-sided, 1-, 2-, 3-, 4-onimoes, and as the pieces are all different this gives us an upper limit to the total area of the squares.

It is fairly straightforward to narrow the required answer down to one of two values on the back of an envelope. But it is fun to make a constructive solution from scratch, so here goes…

The following program looks for possible total areas that can be made into multiple different squares.

We then select pieces with the appropriate area and attempt to construct the different sets of squares.

This Python 3 program is adapted from my initial solution to

Enigma 321. It’s not hugely fast, but it does find the solution in 50s.There is only a single candidate area that can be expressed as the sum of different, non-unit squares in multiple ways.

There are two sets of pieces that can be assembled into the required squares, but they both have the same number of pieces (one set is a mirror image of the other), and so this gives the answer.

Solution:There are 9 jigsaw pieces.The 9 pieces have a total area of 29, and can be assembled into a set of (2×2, 3×3, 4×4) squares, or a set of (2×2, 5×5) squares.

Here is a solution using the 9 pieces:

O1, I2, I3, V3, I4, O4, L4, L4′, Z4.Note that we can’t turn the pieces over, so L4 and its mirror image (L4′) are different pieces (you cannot rotate one of them to give the same shape as the other), as are Z4 and its mirror image (Z4′).

And here is another solution using the 9 pieces:

O1, I2, I3, V3, I4, O4, L4, L4′, Z4′.The second set uses Z4′ instead of Z4. These pieces are mirror images of each other, so any solution for the first set also gives a solution for the second set, by reflecting it.

There are no further solutions, even if we were are allowed to have squares that are the same size.

It occurred to me that the squares are the same sizes as the collection of Rubik’s cubes I have available to me, so here are the diagrams made with cubes:

(I’ve only got one 2×2×2 cube, so it has to be shared between the sets of squares).

LikeLike

## Jim Randell 10:55 am

on23 February 2020 Permalink |I encapsulated the code that deals with polyominoes into a separate file [[

`polyominoes.py`

]] that can be used to solve this puzzle (andEnigma 321), and I switched to using Knuth’sAlgorithm X, rather than the simplistic [[`fit()`

]].So the following program runs in a more reasonable 1.1s.

Run:[ @repl.it ]LikeLike

## Robert Brown 12:57 pm

on25 February 2020 Permalink |This teaser reminds me of enigma 1491 (not on your site?) from 2008. Box of tiles 1×3, 2×4, 3×5 etc. Takes tiles out in order, one at a time, and tries to make a rectangle. Required to find a) smallest possible rectangle & b) next largest. Everyone could all do a) by hand, but b) needed a fairly complex program. Ongoing discussions gradually simplified the program algorithm, and ultimately we got it down to a series of steps that could be followed manually – could be done in about 10 minutes. It’s all on the newenigma site, but you need a user name & password to log in!

LikeLike

## Robert Brown 1:03 pm

on25 February 2020 Permalink |Sorry, I misquoted that slightly – should say ‘required to find how many tiles for smallest rectangle’ (which of course has no gaps or overlaps)

LikeLike

## Jim Randell 2:20 pm

on25 February 2020 Permalink |I remember

Enigma 1491. It was a fun puzzle. My notes for it are here [ @enigmaticcode ].When it was originally published in 2008 I wrote a Perl program to solve it, but that took 50 minutes to run. So while it was running I coded up the same algorithm in C, and that ran in 11 seconds.

When I came to add the puzzle to the

Enigmatic Codesite in 2012 I wrote a Python program using a slightly different approach, and found that it ran in 9.2s. Now the same program runs in just 2.5s (probably due to improvements in thePyPyenvironment — I’m still using the same laptop I was using in 2012).LikeLike