One of my professors told me about a job interview question that I thought was interesting:
Given any 2d array, how would you loop through the array in a "spiral" format?
I thought I would give it a try and I used Excel VBA because I can represent looping through the range of a worksheet visually by coloring which cell I'm in during the loop.
So, if you have a 2d array of:
[1][2][3][4]
[5][6][7][8]
[9][a][b][c]
Looping through would look like:
1, 2, 3, 4, 8, c, b, a, 9, 5, 6, 7
See if you can solve it using VBA and excel. I attached my example, so don't open the code if you want to solve it yourself.
Good luck and have fun!
EDIT: Oh, and please attach a workbook and not your code example, so other people can try without the (easier) temptation to cheat!