aboutsummaryrefslogtreecommitdiff
path: root/challenge-196/sgreen/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-196/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-196/sgreen/python/ch-1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-196/sgreen/python/ch-1.py b/challenge-196/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..57b37a70da
--- /dev/null
+++ b/challenge-196/sgreen/python/ch-1.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+from itertools import combinations
+import sys
+
+def main(n):
+ # Work through all combinations of positions
+ for x in combinations(range(len(n)), 3):
+ i, j, k = sorted(x)
+ if n[i] < n[k] < n[j]:
+ print(f'({n[i]}, {n[j]}, {n[k]})')
+ return
+
+ # No solution is found
+ print('()')
+
+if __name__ == '__main__':
+ # Turn the strings into integers
+ n = [int(i) for i in sys.argv[1:]]
+ main(n)