title: 2-color dithering
body: <p>I have an array of containing a mixture of <code>0</code>s and <code>1</code>s. I want to rearrange the contents of the array so that as many even positions in the array contain <code>0</code> and odd positions contain <code>1</code> as possible, subject to the constraint that the number of <code>0</code>s and <code>1</code>s are unchanged. This means that if the number of <code>0</code>s exceeds the number of <code>1</code>s or vice versa then there will a block at the end of the rearranged array consisting of all-<code>0</code>s or all-<code>1</code>s. How can I do this in one pass, modifying the array in place?</p>
  
  <p>For example:</p>
  
  <pre><code>Input:  {0,1,1,0,1,0,1,0,1,1,1,0,0,1,0,1,1}
  Output: {0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1}
  </code></pre>