aboutsummaryrefslogtreecommitdiff
path: root/challenge-204/sgreen/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-204/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-204/sgreen/python/ch-1.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-204/sgreen/python/ch-1.py b/challenge-204/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..8d81507f84
--- /dev/null
+++ b/challenge-204/sgreen/python/ch-1.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(n):
+
+ # If the last value is less than the first, reverse it
+ if n[0] > n[-1]:
+ n = n[::-1]
+
+ # Go through the positions 0 .. len(n)-2
+ for i in range(len(n)-1):
+ if n[i] > n[i+1]:
+ # If the earlier value is higher, we don't have a solution
+ print(0)
+ return
+
+ # We have a solution
+ print('1')
+
+
+if __name__ == '__main__':
+ # Turn the strings into integers
+ n = [int(i) for i in sys.argv[1:]]
+ main(n)