Skip to content

Instantly share code, notes, and snippets.

@colegleason
Created October 8, 2010 21:54
Show Gist options
  • Select an option

  • Save colegleason/617639 to your computer and use it in GitHub Desktop.

Select an option

Save colegleason/617639 to your computer and use it in GitHub Desktop.
import csv
import itertools
def findsubsets(S,m):
return list(itertools.combinations(S, m))
#numlist = (1, 2, 3, 4, 6)
csvreader = csv.reader(open('numbers.csv','rb'), skipinitialspace=True)
numlist = [int(x) for x in csvreader.next()]
answer = 0
possibles = []
for x in range(3,len(numlist)):
possibles.append(findsubsets(numlist,x))
for x in possibles:
for i in x:
listi = list(i)
max = listi.pop(-1)
if max == sum(listi):
answer += 1
else: pass
print answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment