+1  A: 

I was bored, so I made a python version for you with 9 lines of code inside the loop.

ticker = 0
rows = 4
cols = 4
originalArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
newArray = [None] * (rows * cols)
row = 0
col = 0
dir_x = 1
dir_y = 0
taken = {}

while (ticker < len(originalArray)):
    newArray[row * cols + col] = originalArray[ticker]
    taken[row * cols + col] = True

    if col + dir_x >= cols or row + dir_y >= rows or col + dir_x < 0:
        dir_x, dir_y = -dir_y, dir_x
    elif ((row + dir_y) * cols + col + dir_x) in taken:
        dir_x, dir_y = -dir_y, dir_x

    row += dir_y
    col += dir_x    
    ticker += 1

print newArray
Tuomas Pelkonen
Thank Tuomas, I'll check this right away.
aw
Works like a charm. For me there are a few lines more since I had to solve the multiple assignment (which seam to be pretty handy in python btw). Also you could put the else condition in the if to save one more line. Yeah, I know... :) However, thanks for that.
aw
A: 

You can index into the snake coil directly if you recall that

1 + 2 + 3 + ... + n = n*(n+1)/2
m^2 + m - k = 0  =>  m - (-1+sqrt(1+4*k))/2

and look at the pattern of the coils. (I'll leave it as a hint for the time being--you could also use that n^2 = (n-1)^2 + (2*n+1) with reverse-indexing, or a variety of other things to solve the problem.)

When translating to code, it's not really any shorter than Tuomas' solution if all you want to do is fill the matrix, however.

Rex Kerr