Created
June 25, 2017 15:40
-
-
Save opethe1st/38decbeb5837346485ed1ab0caf0233d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solution = [] | |
def possibleCombinations(N, items): | |
if N < 0: | |
return | |
if N == 0: | |
print solution | |
else: | |
for k in items: | |
key = k | |
v = items[key] | |
del items[k] | |
solution.append(key) | |
possibleCombinations(N - v, items) | |
solution.pop(-1) | |
items[k] = v | |
items = {"a": 23, "b": 34, "c": 36, "d": 64, | |
"e": 50, "f": 50, "g": 40, "h": 60} | |
possibleCombinations(100, items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment