Skip to content

Instantly share code, notes, and snippets.

@latompa
Created December 21, 2009 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save latompa/261274 to your computer and use it in GitHub Desktop.
Save latompa/261274 to your computer and use it in GitHub Desktop.
require 'pp'
def uniq_combos(set)
comb = []
(set.size).times.each do |x|
comb.concat set.combination(x+1).entries
end
comb.sort {|x,y| y.size <=> x.size}
end
pp uniq_combos %w{ice cream parlor}
[["ice", "cream", "parlor"],
["cream", "parlor"],
["ice", "parlor"],
["ice", "cream"],
["parlor"],
["cream"],
["ice"]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment