Skip to content

Instantly share code, notes, and snippets.

@RubyBrewsday
Created April 4, 2014 23:19
Show Gist options
  • Save RubyBrewsday/9984938 to your computer and use it in GitHub Desktop.
Save RubyBrewsday/9984938 to your computer and use it in GitHub Desktop.
Bonus: subsets
Attempt this after you have the other two problems working.
Write a method that, given an array of unique items, finds all the subsets of items:
subsets(["a", "b", "c"]) == [
[], # note that the empty set counts!
["a"], ["a", "b"], ["a", "b", "c"], ["a", "c"]
["b"], ["b", "c"],
["c"]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment