**From New Scientist #2360, 14th September 2002** [link]

I secretly write the 3×3 square:

I then tell you that the horizontal rows of my square were 231, 312 and 123 and the vertical columns 213, 321 and 132, in some order. If you can work out what my square was then it is called a “fitogether”. (If you check you will see this square is not a fitogether).

Similarly, I can start with any *n*×*n* square of numbers where each row and each column contains 1, 2, 3, … *n*. I tell you the rows and columns in some order and you try to work out my square; if you can, it is called a fitogether. We only consider *n* if it is at least 2.

The value of a square of numbers is the number obtained by writing the the rows one after the other in order with the top row at the left. For example, the square above has value 312231123.

Find the bottom row of the fitogether with the smallest value.

[enigma1204]

### Like this:

Like Loading...

This Python 3 program generates Latin Squares of increasing dimensions, until it finds a size with “fitogethers”, and then finds the smallest one. It runs in 7.5s.

Solution:The bottom row of the fitogether with the smallest value is 5, 3, 1, 2, 4.The 5×5 “fitogether” in question is shown below:

Fortunately we don’t have to search very far to find a fitogether, as this program becomes unwieldy above

n=5.The number of Latin Squares

LS(n)gets quite big quite quickly asnincreases (OEIS A002860):