title: How to get list of neighbors with distance N from index in matrix?
body: <p>I have a matrix like this:</p>
  
  <pre><code>35  1   6   26  19  24
  3   32  7   21  23  25
  31  9   2   22  27  20
  8   28  33  17  10  15
  30  5   34  12  14  16
  4   36  29  13  18  11
  </code></pre>
  
  <p>I want a list of neighbors with distance 3 for each cell. For example, 
  the list of neighbors with distance 3 for <code>(1, 1)</code> is:</p>
  
  <pre><code>[8, 28, 33, 17, 26, 21, 22, 17]
  </code></pre>
  
  <p>Visual explanation:</p>
  
  <pre><code>[35]    1   6   |26|   19   24
   3     32   7   |21|   23   25
   31    9    2   |22|   27   20
   -------------------
   8     28   33  |17|   10   15
   -------------------
   30    5    34   12    14   16
   4     36   29   13    18   11
  </code></pre>
  
  <p>The list of neighbors with distance 3 for <code>(3, 3)</code> is</p>
  
  <pre><code>[4, 36, 29, 13, 18, 11, 24, 25, 20, 15, 16]
  </code></pre>
  
  <p>Visual explanation:</p>
  
  <pre><code>35  1   6   26  19  |24|
  3   32  7   21  23  |25|
  31  9   [2] 22  27  |20|
  8   28  33  17  10  |15|
  30  5   34  12  14  |16|
  ------------------------
  4   36  29  13  18  |11|
  ------------------------
  </code></pre>