spiral by nn

n=System.in.text as int
x=l=i=0
y=u=n-1
(n-1..0).each{(it-~it).times{print"$x$y ";i%2?x>l?x--:y<u&&y++:x<u?x++:y>l&&y--};x=i++%2?++l:--u}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page