The 24 magnetic tile puzzle was bought by the author's father in 1976[1]. The object of the puzzle is variable. Two objectives are shown in the instructions to the left. The simplest objective is to place all the tiles so that their touching colors are the same.
Analysis
We have 3 colors, black, red and yellow. This suggests an encoding of each tile as the list [a,b,c,d], with a the color of the bottom of the tile, b the color of the right side of the tile, c the color of the upper side of the tile and d the color of the left side of the puzzle. For example, the tile at the bottom left of the image (tile at square (1,1)) would be encoded as [1,3,2,3].
This encoding induces an equivalence relation rot(c,r), where c and r are the column and row resp., which rotates a given tile around the square center. Under rot(c,r) the puzzle breaks into 3 equivalence classes: The first class consists of the all black, all red and all yellow tiles (3, located at (2,2), (4,5) and (1,6)), which are invariant under any rot(c,r) with 1 value. The second class consists of tiles symmetric around the vertical and horizontal (3, located at (4,1), (1,4) and (4,3)), which are invariant under rot(c,r)=180° with 2 values. The third class consists of the rest of the tiles, which are invariant only under rot(c,r)=360° with 4 values.
Select 3 positions out of 24 for the first class, 3 out of 21 for the second class and the rest for the last class, giving an enumeration of all possible puzzle states as:
We can use Maple to build a graphical representation of the puzzle:
If the colors are represented as a=1=black, b=2=red, c=3=yellow, then each tile can be uniquely identified by its base-3 value, for example as: [a,b,c,d]=(a-1)(b-1)(c-1)(d-1)3=v, and rot(c,r) gives a total of: 18*4+3*2+3*1=81=34 values, so we can encode the puzzle uniquely using a string of length 24 in base 81, as:
For example, using this encoding,
> enc(p);
117782535294698141274684082857347227980565352
> convert(enc(p),base, 81);
[23,45,43,70,58,80,68,0,24,34,51,77,6,37,26,65,16,63,10,19,60,36,40,1]
which can easily be seen to be a unique representation of the puzzle's starting position as shown on the first picture, starting from the bottom left tile, (1,1).
Solving the Puzzle
One set of moves found by the author, gives:
Encoding the moves as the list [rot,c1,r1,c2,r2] and dumping the stack at the end of the worksheet[2], reveals all the moves in reverse:
| stack | rot (° cw) | from | to |
| [2,2,6,4,6] | 180 | 2,6 | 4,6 |
| [1,1,3,3,6] | 90 | 1,3 | 3,6 |
| [0,1,4,2,6] | 0 | 1,4 | 2,6 |
| [-1,2,5,1,6] | -90 | 2,5 | 1,6 |
| [0,4,5,4,5] | 0 | 4,5 | 4,5 |
| [-1,3,2,3,5] | -90 | 3,2 | 3,5 |
| [-1,1,1,2,5] | -90 | 1,1 | 2,5 |
| [2,4,6,1,5] | 180 | 4,6 | 1,5 |
| [-1,4,1,4,4] | -90 | 4,1 | 4,4 |
| [-2,4,4,3,4] | -180 | 4,4 | 3,4 |
| [0,3,5,2,4] | 0 | 3,5 | 2,4 |
| [0,3,4,1,4] | 0 | 3,4 | 1,4 |
| [-1,2,1,4,3] | -90 | 2,1 | 4,3 |
| [-1,2,4,3,3] | -90 | 2,4 | 3,3 |
| [-1,1,5,2,3] | -90 | 1,5 | 2,3 |
| [-1,1,2,1,3] | -90 | 1,2 | 1,3 |
| [0,1,6,4,2] | 0 | 1,6 | 4,2 |
| [-1,3,6,3,2] | -90 | 3,6 | 3,2 |
| [1,4,2,2,2] | 90 | 4,2 | 2,2 |
| [0,2,2,1,2] | 0 | 2,2 | 1,2 |
| [0,4,3,4,1] | 0 | 4,3 | 4,1 |
| [2,3,1,3,1] | 180 | 3,1 | 3,1 |
| [3,3,3,2,1] | 270 | 3,3 | 2,1 |
| [1,2,3,1,1] | 90 | 2,3 | 1,1 |
If we decide to solve it using Maple, it will be a little tricky: We have to build a generator of all available moves, then encode each new move using the above board encoding and keep looking for moves which do not give already gotten encodings.
The equivalence classes found above help with a brute force solution because they filter out certain rotations in the move generator[3], so we can use brute-force on the enumeration with backtracking, until a solution is found.
Here's the result after running Maple for 1567.8 secs = 26.31 mins on the author's mobile Athlon @1.8 GHz:
Dumping the stack after the search, gives:
| stack | rot (° cw) | from | to |
| [0,4,5,4,6] | 0 | 4,5 | 4,6 |
| [2,4,4,4,5] | 180 | 4,4 | 4,5 |
| [0,4,6,4,4] | 0 | 4,6 | 4,4 |
| [1,4,3,4,3] | 270 | 4,3 | 4,3 |
| [0,3,6,4,2] | 0 | 3,6 | 4,2 |
| [0,3,5,4,1] | 0 | 3,5 | 4,1 |
| [2,4,2,3,6] | 180 | 4,2 | 3,6 |
| [0,4,1,3,5] | 0 | 4,1 | 3,5 |
| [0,3,4,3,4] | 0 | 3,4 | 3,4 |
| [0,3,3,3,3] | 0 | 3,3 | 3,3 |
| [3,3,1,3,2] | 90 | 3,1 | 3,2 |
| [0,3,2,3,1] | 0 | 3,2 | 3,1 |
| [3,2,6,2,6] | 90 | 2,6 | 2,6 |
| [0,2,1,1,6] | 0 | 2,1 | 1,6 |
| [3,2,5,2,5] | 90 | 2,5 | 2,5 |
| [0,1,6,1,5] | 0 | 1,6 | 1,5 |
| [3,1,5,2,4] | 90 | 1,5 | 2,4 |
| [0,1,4,1,4] | 0 | 1,4 | 1,4 |
| [1,2,4,2,3] | 270 | 2,4 | 2,3 |
| [0,1,3,1,3] | 0 | 1,3 | 1,3 |
| [1,2,3,2,2] | 270 | 2,3 | 2,2 |
| [2,1,2,1,2] | 180 | 1,2 | 1,2 |
| [1,1,1,2,1] | 270 | 1,1 | 2,1 |
| [0,2,2,1,1] | 0 | 2,2 | 1,1 |
The reader can tweak the Maple worksheet algorithm (by changing the variable border:=true;) to search for solutions which satisfy the two stricter conditions described on the left side of the puzzle in the first picture.
Here's the solution for objective #2, found by Maple with a little help, after making the first 10 moves manually:
Dumping the stack after the search, gives:
| stack | rot (° cw) | from | to |
| [3,3,5,4,5] | 270 | 3,5 | 4,5 |
| [2,2,5,4,4] | 180 | 2,5 | 4,4 |
| [2,3,6,4,3] | 180 | 3,6 | 4,3 |
| [0,3,4,3,6] | 0 | 3,4 | 3,6 |
| [0,1,6,3,5] | 0 | 1,6 | 3,5 |
| [2,2,1,3,4] | 180 | 2,1 | 3,4 |
| [0,4,5,3,3] | 0 | 4,5 | 3,3 |
| [2,3,3,2,6] | 180 | 3,3 | 2,6 |
| [3,2,6,2,5] | 270 | 2,6 | 2,5 |
| [2,1,5,1,5] | 180 | 1,5 | 1,5 |
| [0,1,4,2,4] | 0 | 1,4 | 2,4 |
| [2,2,4,1,4] | 180 | 2,4 | 1,4 |
| [0,1,3,2,3] | 0 | 1,3 | 2,3 |
| [1,1,1,1,3] | 90 | 1,1 | 1,3 |
| [0,4,6,4,1] | 0 | 4,6 | 4,1 |
| [2,3,2,3,1] | 180 | 3,2 | 3,1 |
| [3,1,2,2,1] | 270 | 1,2 | 2,1 |
| [0,3,1,1,1] | 0 | 3,1 | 1,1 |
| [0,2,2,4,2] | 0 | 2,2 | 4,2 |
| [1,4,1,3,2] | 90 | 4,1 | 3,2 |
| [1,4,2,2,2] | 90 | 4,2 | 2,2 |
| [0,4,3,1,2] | 0 | 4,3 | 1,2 |
| [1,2,3,1,6] | 90 | 2,3 | 1,6 |
| [1,4,4,4,6] | 90 | 4,4 | 4,6 |
The combinatorial enumeration above, enumerates all configurations. When a border is observed, as above, the resultant shape is a plane-tiling. Can you enumerate all configurations for the simplest solution (touching faces same)? Can you enumerate all plane-tilings (touching faces plus border)? Are there good chances Maple can find such a solution by brute-force? Can you see what the second condition will give?