## Superpermutations: lower bound

I wrote about superpermutations here: a superpermutation is a string that has as substrings all the permutations of some set of symbols.

For example, there are six permutations of the symbols 1, 2, 3. They are: 123, 132, 213, 231, 312, 321. The string 123121321 has all six of these as substrings – and it’s the shortest string that does, with only one three-character substring that isn’t a permutation: the 121 in the middle.

For larger numbers of symbols it’s impossible to do quite so well. For example, there are 24 different permutations of the symbols 1, 2, 3, 4, and the shortest superpermutation is 123412314231243121342132413214321, which has 33 characters. So there are 30 different four-character substrings, and six of them contain repeated symbols: 1231, 2312; 3121 and 1213 (which overlap with each other); 2132, and 1321.

Here it is again, with the non-permutations highlighted:

123412314231243121342132413214321

No general formula is known for the length of the shortest superpermutation on n symbols. If we denote this length s(n), then it is known that for n ≥ 3,

$n! + (n-1)! + (n-2)! + (n-3) \le s(n)\le \sum_{i=1}^ni!$

and it is known that neither bound is tight in general. We know the lower bound is not tight because s(5) has been computed exactly and is equal to 153, whereas the formula for the lower bound gives 152. We know the upper bound is not tight because there are superpermutations on 6 symbols of length 872, so we know that s(6) ≤ 872, whereas the formula for the upper bound gives 873.

Posted in chatter | 4 Comments

## Squares of squares, and the group of rational points on the circle

The purpose of this post is to describe a slightly different way of thinking about the existence – or otherwise – of a 3×3 magic square of squares. Of course it may not lead to any real progress, but it does at least suggest some natural weaker questions that may be more amenable. It follows on from part 1 and part 2. Continue reading

Posted in chatter, Mathematics | 1 Comment

## Almost-magic squares of squares

In the last post we saw that every 3×3 almost-magic square is a rearrangement of three three-term arithmetic progressions that have the same common difference. In other words, if we pick any three numbers x, y and z, and any common difference d, then the nine numbers

 x–d, x, x+d y–d, y, y+d z–d, z, z+d

can be rearranged to make an almost-magic square

 x z+d y-d z-d y x+d y+d x-d z

where all the rows and columns, and the leading diagonal, add up to x+y+z.

We’re interested in finding almost-magic squares where all the entries are square numbers, so that means we’re particularly interested in three-term arithmetic progressions of squares. Fortunately there is a well-developed theory of these things, which are closely related to Pythagorean triples.

Posted in chatter, Mathematics | 2 Comments

## Magic squares of squares: Part I

A recent Numberphile video discussed an intriguing unsolved problem in number theory: is there a 3×3 magic square whose entries are all square numbers? (Matt Parker proposed a solution which doesn’t quite work: see the video for more. The “Parker square” even has its own Twitter account.)

It turns out that this question leads to some interesting mathematics, which I’m going to have a go at explaining. At the very least I hope to give some insight into why it’s a hard problem.

To reduce the risk that I’ll run out of time and energy before pressing Publish, I’m going to split this post into two or possibly three parts, which I’ll post separately. The first part, which you’re reading right now, gives some background on 3×3 magic squares. The second will explain how to find almost-magic squares of squares using a bit of number theory and computer algebra. By almost-magic I mean that the rows and the columns and one of the two diagonals have the same sum.

The third, if I write it, will be more speculative and look at some possible approaches to either finding the mythical square of squares or proving that it doesn’t exist.

Posted in chatter, Mathematics | 2 Comments

## Counting coins

This afternoon, Matt Locke tweeted the following problem from his nine-year-old daughter’s maths homework:

Posted in algorithms, Mathematics | 14 Comments

The UK Government Statistical Service recently released its good practice guidance for releasing statistics in spreadsheets. While this advice is clearly well-intentioned*, and parts of it are good, the overall effect is to encourage the release of data in formats that are difficult to process by computer. This is a disappointing retrograde step.

Posted in chatter, Kiln | 6 Comments

## Tackling the Minimal Superpermutation Problem

What’s the shortest string that contains every possible permutation of ABCD somewhere inside it? As it happens, it’s 33 letters long: ABCDABCADBCABDCABACDBACBDACBADCBA. A string like this is called a minimal superpermutation.

So what’s the shortest string that contains every possible permutation of ABCDE? It was recently shown that 153 letters is the shortest possible, and that there are eight different superpermutations of this length.

Okay, what about ABCDEF? The answer is that nobody knows. Until this week the shortest known superpermutation of ABCDEF was 873 letters long:

ABCDEFABCDEAFBCDEABFCDEABCFDEABCDFEABCDAEFBCDAEBFCDAEBCFDAEBCDFAEB
CDAFEBCDABEFCDABECFDABECDFABECDAFBECDABFECDABCEFDABCEDFABCEDAFBCED
DFBCAEDBFCAEDBCFAEDBCAFEDBCABDEFCABDECFABDECAFBDECABFDECABDFECABDC
EFABDCEAFBDCEABFDCEABDFCEABDCFEABDCAEFBDCAEBFDCAEBDFCAEBDCFAEBDCAF
EBDCABEFDCABEDFCABEDCFABEDCAFBEDCABFEDCABACDEFBACDEBFACDEBAFCDEBAC
FDEBACDFEBACDBEFACDBEAFCDBEACFDBEACDFBEACDBFEACDBAEFCDBAECFDBAECDF
BAECDBFAECDBAFECDBACEFDBACEDFBACEDBFACEDBAFCEDBACFEDBACBDEFACBDEAF
CBDEACFBDEACBFDEACBDFEACBDAEFCBDAECFBDAECBFDAECBDFAECBDAFECBDACEFB
DACEBFDACEBDFACEBDAFCEBDACFEBDACBEFDACBEDFACBEDAFCBEDACFBEDACBFEDA
CBFAEDCBAFEDCBA


and it was thought that might be the shortest possible.

But we now know it isn’t, because I found a shorter one:

ABCDEFABCDEAFBCDEABFCDEABCFDEACBFDEACFBDEACFDBEACFDEBACFDEABCDFEAB
CDAEFBCDAEBFCDAEBCFDAEBCDFAEBCDAFEBCDABEFCDABECFDABECDFABECDAFBECD
ABFECDABCEFDABCEDFABCEDAFBCEDABFCEDABCFEDACBFEDCABFDECAFBDCEAFBDCA