Skip to content

Instantly share code, notes, and snippets.

@rickhull
Created May 29, 2013 01:28
Show Gist options
  • Save rickhull/5667367 to your computer and use it in GitHub Desktop.
Save rickhull/5667367 to your computer and use it in GitHub Desktop.
def foo(a)
ret = []
1.upto(a.size) { |i| ret << a.combination(i).to_a }
ret
end
foo([1,2,3])
#=> [[[1], [2], [3]], [[1, 2], [1, 3], [2, 3]], [[1, 2, 3]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment