Skip to content

Instantly share code, notes, and snippets.

@emres
Created October 23, 2010 10:05
Show Gist options
  • Save emres/642022 to your computer and use it in GitHub Desktop.
Save emres/642022 to your computer and use it in GitHub Desktop.
subset.py for the last level in challenge.greplin.com
import itertools
my_set = [3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81,
92, 95, 97, 99]
def greplin_condition(S):
max_item = max(S)
S.remove(max_item)
if sum(S) == max_item:
return True
else:
return False
a = 0
for i in range(3, len(my_set)):
for s in itertools.combinations(my_set, i):
if greplin_condition(list(s)):
a = a + 1
print a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment