One approach would be the following:
-
Map each ring into a line starting at the top left and working clockwise. So:
A B C D
E F G H
I J K L
M N O P
Becomes:
outer ring: ABCDHLPONMIE. Ring size = 4
inner ring: FGKJ. Ring size = 2 -
move the last 'ring size - 1' characters to the beginning of a new array
ABCDHLPON MIE //extract the last 3 as ring size = 4
-> MIE //new array
FGK J //extract the last 1 as ring size = 2
-> J //new array
-
concatenate the rest:
MIE ABCDHLPON
J FGK -
shift each line back into a ring (inverse of step 1)
M I E A
N J F B
O K G C
P L H D
As for realising it in code, the difficult bit is going to be extracting each ring. But it is doable. If you design a function to extract a ring of a specified size, then you could call that same function for each of the rings in turn, and it could be scaled up to 8x8 easily that way. It would be also sensible to have the function be able to do the inverse to put the lines back into the ring which would be the same code as extracting them only moving flipping destination and source.
I'll write a few lines of code as a possible hint.