# Solving the Topsy Turvy

I have a puzzle in my office called the Topsy Turvy, designed by M. Oskar van Deventer, based on ideas of Igor Kriz, a topologist at the University of Michigan. (You can read the Scientific American article by Kriz and undergraduate Paul Siegel here.) The puzzle has 12 tokens numbered 1 through 12, which start off in order. There are two possible "moves", called Left and Right. Left (L), applied to the starting configuration, permutes them to 11 9 7 5 3 1 2 4 6 8 10 12. Right (R), applied to the starting configuration, permutes them to 2 4 6 8 10 12 11 9 7 5 3 1. The group generated by these permutations is one of the sporadic simple groups, called the "Mathieu 12" group, and is index 5040 in S_12.

In the fall of 2010, I asked my first quarter honors algebra (Math 120) class how to solve the puzzle. I was pleased and surprised to get a number of solutions. I'd asked for a computer implementation, basically because I thought a non-computer solution (one that could be communicated in text) would be unreasonable, but three people gave me explicit algorithms that are human-readable.

The computer solvers (along with their language of choice, where I remember) were the following. Many find the optimal solution.

• Carl Case (C++, web-based),
• David Fisher (googleapp, thus web-based),
• Brian Hooi,
• Amanda Howard,
• Gyujin Oh (C++),
• David Kamm,
• Justin Lebar (python, download and run \$ python puzzle.py 7 8 9 10 11 12 1 2 3 4 5 6),
• Tom McLaughlin (Visual Studio 2008, zipped),
• Jaehyun Park (C++),
• Greg Peairs (ruby, web-based); here is another version that will take a defective puzzle and put the top 5 in the right place,
• Alex Ryan (Windows 7),
• Aubrey Shapero (C++),
• Nate Stockham (matlab): load these files into the current directory, and load the .mat file BST_M12 such that the variable BST_M12 is in the workspace. Now, take whatever input you want as an array with 12 elements (ie: [1 2 3 4 5 6 7 8 9 10 11 12])and enter into the command line this line:

[solvable, solution] = M12_solve(BST_M12, input)

and