title: Auto complete an array according a vector
body: <p>I have an array of 16 squares and I would like to auto complete it with integers values depending of the position in the array and the vector TOP_RIGHT.</p>
  
  <pre><code>TOP_RIGHT = 3
  
  # Build the array...
  @top_right = Array.new(16, 0)
  @top_right.each_index do |square|
    @top_right[square] = square / TOP_RIGHT if (0...16).include?(square - TOP_RIGHT)
  end
  
  # Print the array...
  i = 0
  @top_right.each do |square|
    puts if i % 4 == 0
    print "#{square} "
  i += 1
  end
  </code></pre>
  
  <p>My code seems to be okay, but after testing the result is:</p>
  
  <pre><code>0 0 0 1 
  1 1 2 2 
  2 3 3 3 
  4 4 4 5
  </code></pre>
  
  <p>I would like to get this array:</p>
  
  <pre><code>0 0 0 0 
  1 1 1 0 
  2 2 1 0 
  3 2 1 0
  </code></pre>
  
  <p>Do you think it is possible, using array and simple Ruby methods?</p>
  
  <p>Thanks, and happy end year!</p>
  
  <p>Edit:</p>
  
  <p>In the previous example, TOP_RIGHT is a vector like and its value is the number of cases that we can add or sub in order to go from the source square to the destination square (which is on top-right).</p>
  
  <p>For example if I get this other vector: TOP, its value is 4 and the generated array can be:</p>
  
  <pre><code># print_array(4)
  0 0 0 0 
  1 1 1 1 
  2 2 2 2
  3 3 3 3
  </code></pre>
  
  <p>...and if the vector is RIGHT, its value is -1 and the array can be:</p>
  
  <pre><code># print_array(-1)
  3 2 1 0 
  3 2 1 0
  3 2 1 0
  3 2 1 0
  </code></pre>
  
  <p>Isn't it a little beat tricky? :)
  I don't see how to process for designing a constructor which can build such arrays, by passing a value of a vector.</p>