Skip to content

Instantly share code, notes, and snippets.

@robbywalker
Created October 21, 2010 23:05
Show Gist options
  • Save robbywalker/639562 to your computer and use it in GitHub Desktop.
Save robbywalker/639562 to your computer and use it in GitHub Desktop.
David Koblas's one-liner for GPCv1 Level 3
from itertools import combinations, chain
nums = tuple([int(v) for v in "3 4 9 14 15 19 28 37 47 50 54 56 59 61 70 73 78 81 92 95 97 99".split(' ') if v.strip()])
print sum([1 for v in chain(*[combinations(nums, r) for r in range(3, len(nums))]) if sum(v[0:-1]) == v[-1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment