title: Distance between elements in 2D array
body: <p>How can I determine the distance between 1's in a 2D array. For example, we have a 2D array like this:</p>
  
  <pre><code>0 0 0 0
  0 0 0 1
  1 0 0 0
  1 0 0 0
  </code></pre>
  
  <p>The algorithm has to output the distance from each element to the nearest 1. Like this:</p>
  
  <pre><code>2 3 2 1
  1 2 1 0
  0 1 2 1
  0 1 2 2
  </code></pre>
  
  <p>How can I solve it ?</p>