Given an array ['a', 'b', 'c', 'd', 'e', 'f'], how would I get a list of all subsets containing two, three, and four elements?
['a', 'b', 'c', 'd', 'e', 'f']
I'm brand new to Ruby (transition from C #) and I'm not sure what the "Ruby Way" is.
Mark Array # Combination
Then something like this:
2.upto(4) { |n| array.combination(n) }
Tweaking basicxman a bit:
2.upto(4).flat_map { |n| array.combination(n).to_a } #=> [["a", "b"], ["a", "c"], ["a", "d"], ..., ["c", "d", "e", "f"]]