title: Binary Sequence Combination Generator, in Ruby
body: <p>Code works, but feels very brute force, suggestions?</p>
  
  <p>Goal of the code is to supply an array length, and then as fast as possible generate all possible unique binary combinations with that array length. </p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>class Array
    def sequence(i = 0, *a)
      return [a] if i == size
      self[i].map {|x|
        sequence(i+1, *(a + [x]))
      }.inject([]) {|m, x| m + x}
    end
  end
  
  
  [(0..1),(0..1),(0..1)].sequence
  </code></pre>
  
  <p><strong>OUTPUTS:</strong></p>
  
  <pre><code>[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
  </code></pre>