title: Spliting 2D array into sections
body: <p>For a task in my Algorithms and Data Structures lecture I need to find a way to split a given 2D array into sections. Here is a example:
  The program is gets a Integer <code>k&gt;0</code> at the start. The arrays size is <code>[k*k]x[k*k]</code> For <code>k=3</code> it would be something like:</p>
  <pre><code>2  2  0  1  0  0  0  1  1  
  1  0  1  2  1  0  1  0  0  
  1  1  1  0  1  2  1  1  2  
  2  2  2  2  2  0  0  2  0  
  0  0  0  1  1  2  2  1  2  
  1  2  2  1  2  0  0  0  1  
  0  1  0  1  0  0  2  1  1  
  2  1  0  1  0  2  2  2  2  
  1  0  1  2  2  2  2  1  2  
  </code></pre>
  <p>I now want to view the array as sections of size <code>k*k</code>:</p>
  <pre><code>2  2  0    1  0  0    0  1  1    
  1  0  1    2  1  0    1  0  0    
  1  1  1    0  1  2    1  1  2    
  
  2  2  2    2  2  0    0  2  0    
  0  0  0    1  1  2    2  1  2    
  1  2  2    1  2  0    0  0  1    
  
  0  1  0    1  0  0    2  1  1    
  2  1  0    1  0  2    2  2  2    
  1  0  1    2  2  2    2  1  2  
  </code></pre>
  <p>My task now is to add the integers of each segment und store them in an array of size <code>k*k</code>. For now I have failed miserably getting only wrong outputs. Is there a trick to this or some kind of library which features such a functionality?</p>