Skip to content

Instantly share code, notes, and snippets.

@asuka-mirai
Created January 21, 2017 04:20
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 asuka-mirai/cc44687dc2bc88299b0819f5d8ea8450 to your computer and use it in GitHub Desktop.
Save asuka-mirai/cc44687dc2bc88299b0819f5d8ea8450 to your computer and use it in GitHub Desktop.
import itertools as it
from collections import Counter
l = [1,14,14,4,11,7,6,9,8,10,10,5,13,2,3,15]
ans = []
for i in range(len(l)):
for d in it.combinations(l,i):
ans.append(sum(d))
counter = Counter(ans)
for num, cnt in counter.most_common():
print(num, cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment