title: Snake traversal of 2D NumPy array
body: <p>I have the following 2D array:</p>
  
  <pre><code>In [173]: arr
  Out[173]: 
  array([[ 1,  2,  3,  4],   # -&gt; -&gt; -&gt; -&gt;
         [ 5,  6,  7,  8],   # &lt;- &lt;- &lt;- &lt;-
         [ 9, 10, 11, 12],   # -&gt; -&gt; -&gt; -&gt;
         [13, 14, 15, 16],   # &lt;- &lt;- &lt;- &lt;-
         [17, 18, 19, 20]])  # -&gt; -&gt; -&gt; -&gt;
  </code></pre>
  
  <p>And I'd like to traverse the array in a <a href="https://stackoverflow.com/questions/33833120/traversing-grid-in-a-snake-like-pattern">snake-like pattern</a> starting from top left element and ending up in bottom right element.</p>
  
  <p>As of now, I have this uninteresting way of solving:</p>
  
  <pre><code>In [187]: np.hstack((arr[0], arr[1][::-1], arr[2], arr[3][::-1], arr[4]))
  Out[187]: 
  array([ 1,  2,  3,  4,  8,  7,  6,  5,  9, 10, 11, 12, 16, 15, 14, 13, 17,
         18, 19, 20])
  </code></pre>
  
  <p>How can we do it with minimal effort, without looping and not too much hard-coding?</p>