On Tue, 2 Sep 2008 11:39:54 -0700 (PDT), indian_gaurav
<> wrote, quoted or indirectly quoted
someone who said :
>7 8 9 10
>
>6 1 2 11
>
>5 4 3 12
>
>16 15 14 13
So how did you create that? You first decided how many rows/columns
you need. You can do that with sqrt and rounding up. See
http://mindprod.com/jgloss/round.html
Then you had to find the center of the matrix. That is matter of
dividing the size by 2 with possibly a one off adjust.
Then you have a loop that spirals outward. It starts in the bottom
left corner and spiral clockwise
you spiral out 0, 1, 2 , 3 etc rows. So compute the co-ordinates of
the bottom right corner of the next layer. Now plop down the numbers
for the left, top, right and bottom sides, incrementing your number by
one each time. you continue with the loop for the next layer out.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com