Created
September 3, 2014 09:42
-
-
Save yuheiomori/13227f62caa54ecdeb9d to your computer and use it in GitHub Desktop.
sum to zero (CodeEval) in python 3.x
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
# coding=utf-8 | |
import sys | |
import itertools | |
def main(): | |
with open(sys.argv[1], 'r') as f: | |
for line in f: | |
digits = map(lambda e: int(e), line.rstrip().split(",")) | |
print(len([combination for combination | |
in itertools.combinations(digits, 4) | |
if sum(combination) == 0])) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment