title: creating a spiral array in python?
body: <p>Me and my mate were trying to create a fun game in python where the elements entered in the array are accessed in a spiral manner. I have tried few methods like one given below (<a href="https://stackoverflow.com/a/398302/5717589">source</a>).</p>
  
  <pre><code>def spiral(X, Y):
    x = y = 0
    dx = 0
    dy = -1
    for i in range(max(X, Y)**2):
      if (-X/2 &lt; x &lt;= X/2) and (-Y/2 &lt; y &lt;= Y/2):
          print (x, y)
          # DO STUFF...
      if x == y or (x &lt; 0 and x == -y) or (x &gt; 0 and x == 1-y):
          dx, dy = -dy, dx
      x, y = x+dx, y+dy
  </code></pre>
  
  <p>The above statement accesses the elements in spiral loop and prints them for a defined array AE. I would like to know how can I transform a given array AE to a spiral one  </p>
  
  <p><a href="https://i.stack.imgur.com/ln6SR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ln6SR.png" alt="Array AE"></a></p>