**From New Scientist #2637, 5th January 2008**

Joe cut out a number of small square cards. On some of them he drew a thin red line joining the centres of two opposite sides and on the others he drew a thin red line joining the centres of two adjacent sides.

Penny’s challenge was to select 24 cards and arrange them in a 6-card by 4-card rectangle so as to produce a number of small areas, each with a complete single boundary of thin red lines, with a total area equal to five-sixteenths of the total card area.

Penny could choose any combination of cards – for example, 10 of the first and 14 of the second – but only some of the combinations would lead to her meeting the challenge.

How many of the combinations?

[enigma1475]

### Like this:

Like Loading...

*Related*

I thought this sounded like a tricky one to code up, but when I set about it it was actually surprisingly simple, but still fun. The following recursive Python approach runs in 150ms.

Solution: There are 5 different combinations.Instead of considering two different types of card and worrying about their rotations and determining the interior and exterior of shapes I instead considered 12 possible tiles which take all possible arrangements into account.

The edges of the tiles are split into two segments and labelled either 0 or 1 (for “0utside” and “1nside” to distinguish the exterior and interior segments). I then consider a 6 x 8 grid where the perimeter is filled with empty tiles that consist entirely of exterior edges. The problem is then simply to fit tiles into the grid so that the edges match up. And find solutions where the interior (coloured in) area is 60 (measuring in eighths of squares, so the entire 4 x 6 grid has an area of 192).

It turns out the are 59 different grids (although fewer if you eliminate duplicates grids by symmetry, and fewer still if you eliminate duplicate grids that use the same shapes, but rearranged).

It turns out that each of these grids is composed of the following 15 different enclosed shapes.

and here are example solutions using, 4 type A and 20 type B cards (there are 4 such grids):

6 type A and 18 type B cards (there are 4 such grids):

8 type A and 16 type B cards (there are 22 such grids):

10 type A and 14 type B cards (there are 20 such grids):

12 type A and 12 type B cards (there are 9 such grids):

The following code is augmented to produce all grid patterns (regardless of area), and attempt an ASCII art representation of the layout:

The maximum enclosed area you can make is 13.5 tiles, using a grid that uses 12 type A and 12 type B cards. It looks like this:

Brilliant, Jim. Just the sort of detailed analysis we appreciate, as opposed to the one-line answers published in the magazine.