After Gribouillis' awesome solution that works for odd and uneven numbers,
i tried to make something that the TS might be able to do, without recursion.
For the time being it works only for 3 and 5, perhaps with some work it will do all odd numbers.
As this is homework, no code, but the idea is:
- Start from the middle, and work you way around that, like a spider. (first 25, then 24, etc)
-Each square around the middle has 4 sides, getting longer for each leayer.
These useless exercises are sometimes great fun and instructive.
Paul
i tried to make something that the TS might be able to do, without recursion.
For the time being it works only for 3 and 5, perhaps with some work it will do all odd numbers.
As this is homework, no code, but the idea is:
- Start from the middle, and work you way around that, like a spider. (first 25, then 24, etc)
-Each square around the middle has 4 sides, getting longer for each leayer.
These useless exercises are sometimes great fun and instructive.

Paul
Output:[1, 2, 3]
[8, 9, 4]
[7, 6, 5]
[1, 2, 3, 4, 5]
[16, 17, 18, 19, 6]
[15, 24, 25, 20, 7]
[14, 23, 22, 21, 8]
[13, 12, 11, 10, 9]
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.