**From New Scientist #2757, 24th April 2010** [link]

If you take a domino set and discard all those dominoes which involve a 5 or a 6, leaving 15 dominoes with a 0, 1, 2, 3 or 4 at each end, then the rest can be laid out, spotty sides up, to form a 5-by-6 rectangle. Then, taking the number of spots in each square as that square’s value, the product of each row can be calculated by multiplying together the values of the six squares in that row.

Your task is to lay out the dominoes so that the five products are all different, less than 1000, and in increasing order as you come down the rectangle. Just one row must have a product which is odd, just one must have a product which is a power of 2, and just one other must have a product which is a non-zero perfect square.

List the products of the five rows.

[enigma1592]

### Like this:

Like Loading...

This one is easier to solve with pencil and paper, than it is to make a program to try all possibilities. Nevertheless here is a programmatic solution.

It seemed that generating the entire solution space and then looking for an answer would take a long time, so I split the problem into two phases (much like my paper solution). The first phase considers the possible partitioning of the the six 1’s, 2’s, 3’s and 4’s to create four rows with the necessary products. Careful reading of the puzzle is required, the “just one other” part means that the square must be from one of the rows other than the odd number and the power of two. The second phase is to take each of the candidate set of rows and try to tile it with the dominoes, generating and testing possibilities for each row in turn to avoid having to test huge numbers of potential grids. Once we find a suitable tiling of the grid we stop looking.

In the end the program runs in a very satisfactory 152ms.

Run:[ @repl.it ]Solution:The products of the rows are 0, 24, 27, 512 and 576.