Created
October 23, 2010 10:05
-
-
Save emres/642022 to your computer and use it in GitHub Desktop.
subset.py for the last level in challenge.greplin.com
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
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