diff options
Diffstat (limited to 'challenge-203/sgreen/python/ch-1.py')
| -rw-r--r-- | challenge-203/sgreen/python/ch-1.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-203/sgreen/python/ch-1.py b/challenge-203/sgreen/python/ch-1.py new file mode 100644 index 0000000000..cc1bc522e9 --- /dev/null +++ b/challenge-203/sgreen/python/ch-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +from itertools import combinations +import sys + +def main(n): + solutions = 0 + + # Work through all combinations of positions + for x in combinations(range(len(n)), 4): + i, j, k, l = sorted(x) + if n[i] + n[j] + n[k] == n[l]: + solutions += 1 + + # No solution is found + print(solutions) + +if __name__ == '__main__': + # Turn the strings into integers + n = [int(i) for i in sys.argv[1:]] + main(n) |
