3 |
1 |
4 |
2 |

4 |
2 |
3 |
1 |

1 |
4 |
2 |
3 |

2 |
3 |
1 |
4 |

Place the numbers 1 to N into an NxN square, such that each number appears once in each row and column. Then, starting in the upper left square, move to the bottom right square. On each move, you may move up, down, left or right, but you must travel exactly as many squares as the number you start on. You do not need to change direction on each move. You may cross your path, and you must always finish your move on a previously not visited square ("visited" = stopped on.) Maximize the sum of the numbers at the visited squares. Solve for N=3,4,5,6. (You're welcome to solve for higher, too.)

For example, for the 4x4 above, a possible path moves from the 3 to the bottom-left 2, visiting these numbers in order: 3, 2, 1, 4, for a sum of 10. A longer path moves from the 3 to the top-right 2, visiting : 3, 2, 1, 2, 1, 3, 1, 2, 1, 4 for a sum of 20.

Source: Original.

Solution

Mail to Ken