Skip to main content
Expanded thoughts towards a proof, with the given magic square proven unreachable, but other candidates still seeming plausible.
Source Link
Steve
  • 3.9k
  • 12
  • 34

Following the removal of the tag from this puzzle, this answer initially treats it as a .

No. It
It is not possible using the rules given. Unfortunately the damage to this magic square is beyond the possibility of repairing it with this method.
The obvious secondary question is "why not". This probably needs some better insight into the problem to answer properly, and some intermediate lemmas that can be used to simplify the problem to a point where heavy use of computing resources is not necessary...
but at present my only answer to the "why not" question is "Computer says no!".

To the more specific question of whether it is possible to restore the magic as the given magic square, this is now proven impossible in one of the later spoiler blocks following "first stage of a proof".

Which would seem to give the first stage of a proof

of impossibility of reaching that particular grid, which can continue as follows...
Each swap between tiles $k$ and $j$ where $k<j$ uses up $k+1$ "moves", and each tile $k$ can only be involved at least $k$ times.
48 half-swaps might conceivably be arranged with 24 swaps (where every swap moves both tiles towards their target position), and these might conceivably all involve the lowest numbered tiles.
so we can have 1 swap involving the '1' tile that uses up 2 moves, 2 swaps that use 3 moves, 3 swaps that use 4 moves, 4 swaps that use 5 moves, 5 swaps that use 6 moves, and 6 swaps that use 7 moves for a total of 21 swaps costing 112 moves. To get to 24 swaps, we'd need 3 more swaps involving the '7' tile, costing 8 moves each for a total of 136.
This is exactly equal to the total number of moves present on the starting grid, so in order for there to be a solution that finishes on that particular magic square, every move would need to move both tiles towards their target, with the smaller tile no larger than '7' and the larger tile no smaller than '7'.
Observing the right hand column, this is impossible, because 16, 10, 14, 15 must all swap "out" of the right hand column, but to do so must swap with a tile 7 or lower moving towards its destination to avoid breaking the budget of 136 moves. However, only two tiles lower than 7 are moving into that column, the 4 and 5.
Therefore there is no possible solution of any sequence of swaps to reach the given magic square.

Taking this specific proof into account,

the "move budget" seems likely to be a major factor in a more complete proof. The 22 or 24 half-moves for the "nearest" and "second-nearest" magic squares to the starting state certainly can't be ruled out with a similarly simple argument. The heuristic in the program assumed that a tile can be moved $n$ places using $n$ moves, which is only the case if it is the lower tile involved in the swap, or if it is swapping with the '1' (which can only occur once for any tile). In particular, the '16' tile will always be the larger tile involved in the swap, so uses up its score very quickly... indeed, an alternative proof of impossibility for the given magic square is that the '16' tile cannot reach the opposite corner, as it involves 6 swaps, and each swap costs the value of the tile it swaps with... even swapping with the lowest numbers would cost $1+2+3+4+5 = 15$ for 5 moves. Tiles of lower value can make 6 moves, but effectively "steal" part of the move budget from other tiles, as they must be the lower tile involved in at least some swaps.
For a next step, I'd probably look more closely at the two magic squares shown above, which require only 22 or 24 half-swaps. If there was yet another bug in my program, so that I was wrong about there being no solution, those would be the most likely candidates... and if it's impossible for any magic square, demonstrating why it's impossible for those specific ones which require the smallest net movement of tiles would seem likely to inform why it's impossible in the general case.

Following the removal of the tag from this puzzle, this answer treats it as a .

No. It is not possible using the rules given. Unfortunately the damage to this magic square is beyond the possibility of repairing it with this method.
The obvious secondary question is "why not". This probably needs some better insight into the problem to answer properly, and some intermediate lemmas that can be used to simplify the problem to a point where heavy use of computing resources is not necessary...
but at present my only answer to the "why not" question is "Computer says no!".

Following the removal of the tag from this puzzle, this answer initially treats it as a .

No.
It is not possible using the rules given. Unfortunately the damage to this magic square is beyond the possibility of repairing it with this method.
The obvious secondary question is "why not". This probably needs some better insight into the problem to answer properly, and some intermediate lemmas that can be used to simplify the problem to a point where heavy use of computing resources is not necessary...
but at present my only answer to the "why not" question is "Computer says no!".

To the more specific question of whether it is possible to restore the magic as the given magic square, this is now proven impossible in one of the later spoiler blocks following "first stage of a proof".

Which would seem to give the first stage of a proof

of impossibility of reaching that particular grid, which can continue as follows...
Each swap between tiles $k$ and $j$ where $k<j$ uses up $k+1$ "moves", and each tile $k$ can only be involved at least $k$ times.
48 half-swaps might conceivably be arranged with 24 swaps (where every swap moves both tiles towards their target position), and these might conceivably all involve the lowest numbered tiles.
so we can have 1 swap involving the '1' tile that uses up 2 moves, 2 swaps that use 3 moves, 3 swaps that use 4 moves, 4 swaps that use 5 moves, 5 swaps that use 6 moves, and 6 swaps that use 7 moves for a total of 21 swaps costing 112 moves. To get to 24 swaps, we'd need 3 more swaps involving the '7' tile, costing 8 moves each for a total of 136.
This is exactly equal to the total number of moves present on the starting grid, so in order for there to be a solution that finishes on that particular magic square, every move would need to move both tiles towards their target, with the smaller tile no larger than '7' and the larger tile no smaller than '7'.
Observing the right hand column, this is impossible, because 16, 10, 14, 15 must all swap "out" of the right hand column, but to do so must swap with a tile 7 or lower moving towards its destination to avoid breaking the budget of 136 moves. However, only two tiles lower than 7 are moving into that column, the 4 and 5.
Therefore there is no possible solution of any sequence of swaps to reach the given magic square.

Taking this specific proof into account,

the "move budget" seems likely to be a major factor in a more complete proof. The 22 or 24 half-moves for the "nearest" and "second-nearest" magic squares to the starting state certainly can't be ruled out with a similarly simple argument. The heuristic in the program assumed that a tile can be moved $n$ places using $n$ moves, which is only the case if it is the lower tile involved in the swap, or if it is swapping with the '1' (which can only occur once for any tile). In particular, the '16' tile will always be the larger tile involved in the swap, so uses up its score very quickly... indeed, an alternative proof of impossibility for the given magic square is that the '16' tile cannot reach the opposite corner, as it involves 6 swaps, and each swap costs the value of the tile it swaps with... even swapping with the lowest numbers would cost $1+2+3+4+5 = 15$ for 5 moves. Tiles of lower value can make 6 moves, but effectively "steal" part of the move budget from other tiles, as they must be the lower tile involved in at least some swaps.
For a next step, I'd probably look more closely at the two magic squares shown above, which require only 22 or 24 half-swaps. If there was yet another bug in my program, so that I was wrong about there being no solution, those would be the most likely candidates... and if it's impossible for any magic square, demonstrating why it's impossible for those specific ones which require the smallest net movement of tiles would seem likely to inform why it's impossible in the general case.

added 92 characters in body
Source Link
Steve
  • 3.9k
  • 12
  • 34

by how many half-swaps would be needed to "restore the magic" if each tile could move the minimum distance between its jumbled state and the magic square. In particular, after adding some further diagnostic output, I got the following:

At least 22 half-swaps required for
  1₁ | G₊ | B₊ | 6₆
 ----+----+----+----
  D₊ | 4₄ | 7₇ | A₊
 ----+----+----+----
  8₈ | 9₉ | E₊ | 3₃
 ----+----+----+----
  C₊ | 5₅ | 2₂ | F₊

 At least 24 half-swaps required for
  B₊ | 6₆ | 7₇ | A₊
 ----+----+----+----
  1₁ | G₊ | D₊ | 4₄
 ----+----+----+----
  E₊ | 3₃ | 2₂ | F₊
 ----+----+----+----
  8₈ | 9₉ | C₊ | 5₅

 At least 26 half-swaps required for
 [14 possible magic squares which have '1' in R1C1 or R2C1]

by how many half-swaps would be needed to "restore the magic". In particular, after adding some further diagnostic output, I got the following:

At least 22 half-swaps required for
  1₁ | G₊ | B₊ | 6₆
 ----+----+----+----
  D₊ | 4₄ | 7₇ | A₊
 ----+----+----+----
  8₈ | 9₉ | E₊ | 3₃
 ----+----+----+----
  C₊ | 5₅ | 2₂ | F₊

 At least 24 half-swaps required for
  B₊ | 6₆ | 7₇ | A₊
 ----+----+----+----
  1₁ | G₊ | D₊ | 4₄
 ----+----+----+----
  E₊ | 3₃ | 2₂ | F₊
 ----+----+----+----
  8₈ | 9₉ | C₊ | 5₅

 At least 26 half-swaps required for
 [14 possible magic squares which have '1' in R1C1 or R2C1]

by how many half-swaps would be needed to "restore the magic" if each tile could move the minimum distance between its jumbled state and the magic square. In particular, after adding some further diagnostic output, I got the following:

At least 22 half-swaps required for
  1₁ | G₊ | B₊ | 6₆
 ----+----+----+----
  D₊ | 4₄ | 7₇ | A₊
 ----+----+----+----
  8₈ | 9₉ | E₊ | 3₃
 ----+----+----+----
  C₊ | 5₅ | 2₂ | F₊

 At least 24 half-swaps required for
  B₊ | 6₆ | 7₇ | A₊
 ----+----+----+----
  1₁ | G₊ | D₊ | 4₄
 ----+----+----+----
  E₊ | 3₃ | 2₂ | F₊
 ----+----+----+----
  8₈ | 9₉ | C₊ | 5₅

 At least 26 half-swaps required for
 [14 possible magic squares which have '1' in R1C1 or R2C1]

Further thoughts, which may help towards further analysis (either proving my main program wrong, or allowing a manual proof to be better constructed)
Source Link
Steve
  • 3.9k
  • 12
  • 34

After further consideration, it's possible to rank the magic squares

by how many half-swaps would be needed to "restore the magic". In particular, after adding some further diagnostic output, I got the following:

At least 22 half-swaps required for
  1₁ | G₊ | B₊ | 6₆
 ----+----+----+----
  D₊ | 4₄ | 7₇ | A₊
 ----+----+----+----
  8₈ | 9₉ | E₊ | 3₃
 ----+----+----+----
  C₊ | 5₅ | 2₂ | F₊

 At least 24 half-swaps required for
  B₊ | 6₆ | 7₇ | A₊
 ----+----+----+----
  1₁ | G₊ | D₊ | 4₄
 ----+----+----+----
  E₊ | 3₃ | 2₂ | F₊
 ----+----+----+----
  8₈ | 9₉ | C₊ | 5₅

 At least 26 half-swaps required for
 [14 possible magic squares which have '1' in R1C1 or R2C1]

A better-directed (possibly manual) search might prefer those magic squares to the one given in the question, because the equivalent diagnostics for the given magic square are:

At least 48 half-swaps required for
  1₁ | F₊ | E₊ | 4₄
 ----+----+----+----
  A₊ | B₊ | 8₈ | 5₅
 ----+----+----+----
  7₇ | 6₆ | 9₉ | C₊
 ----+----+----+----
  G₊ | 2₂ | 3₃ | D₊

After further consideration, it's possible to rank the magic squares

by how many half-swaps would be needed to "restore the magic". In particular, after adding some further diagnostic output, I got the following:

At least 22 half-swaps required for
  1₁ | G₊ | B₊ | 6₆
 ----+----+----+----
  D₊ | 4₄ | 7₇ | A₊
 ----+----+----+----
  8₈ | 9₉ | E₊ | 3₃
 ----+----+----+----
  C₊ | 5₅ | 2₂ | F₊

 At least 24 half-swaps required for
  B₊ | 6₆ | 7₇ | A₊
 ----+----+----+----
  1₁ | G₊ | D₊ | 4₄
 ----+----+----+----
  E₊ | 3₃ | 2₂ | F₊
 ----+----+----+----
  8₈ | 9₉ | C₊ | 5₅

 At least 26 half-swaps required for
 [14 possible magic squares which have '1' in R1C1 or R2C1]

A better-directed (possibly manual) search might prefer those magic squares to the one given in the question, because the equivalent diagnostics for the given magic square are:

At least 48 half-swaps required for
  1₁ | F₊ | E₊ | 4₄
 ----+----+----+----
  A₊ | B₊ | 8₈ | 5₅
 ----+----+----+----
  7₇ | 6₆ | 9₉ | C₊
 ----+----+----+----
  G₊ | 2₂ | 3₃ | D₊

A couple of minor tidy-ups, and added a non-answer section to gather thoughts so far towards how it might be solved "properly"
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading
Added TL/DR summary, and fixed some earlier editing errors.
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading
Post Undeleted by Steve
Updated ready for undeletion following much more tweaks to the search program than I'd ever envisaged.
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading
Post Deleted by Steve
Further update - less progress than expected at last update, so will delete answer within 24 hours if no further progress.
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading
Found another significant bug - fixed, so running again...
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading
Source Link
Steve
  • 3.9k
  • 12
  • 34
Loading