about | help | code help+videos | done | prefs |
We define the function combinations(things, k) to be a list of all the subsets of exactly k elements of things. You can generate subsets by counting up in binary. If the binary number has exactly k 1's then this is a subset to add to the list. combinations(["A", "B", "C"], 2) → ["AB", "AC", "BC"] combinations(["A", "B", "C"], 3) → ["ABC"] combinations(["A", "B", "C", "D", "E", "F"], 5) → ["ABCDE", "ABCDF", "ABCEF", "ABDEF", "ACDEF", "BCDEF"] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 200 Post-solution available
Copyright Nick Parlante 2017 - privacy