Skip to content

Instantly share code, notes, and snippets.

@LTe
Created March 31, 2010 14:22
Show Gist options
  • Save LTe/350378 to your computer and use it in GitHub Desktop.
Save LTe/350378 to your computer and use it in GitHub Desktop.
irb(main):027:0> array2 = []; array = []
=> []
irb(main):028:0> 3.imes {|x| array << x}
irb(main):028:0> array = []
=> []
irb(main):029:0> 3.times {|x| array << x}
=> 3
irb(main):030:0> (1..3).each { |x| array.combination(x) { |y| array2 << y } }
=> 1..3
irb(main):031:0> array2
=> [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment