From caba8c35b04f4f90f507b9ae100b8e1aadd4b1dd Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sat, 20 Nov 2021 17:18:51 +1100 Subject: sgreen solutions to challenge 139 --- challenge-139/sgreen/python/ch-1.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 challenge-139/sgreen/python/ch-1.py (limited to 'challenge-139/sgreen/python/ch-1.py') diff --git a/challenge-139/sgreen/python/ch-1.py b/challenge-139/sgreen/python/ch-1.py new file mode 100755 index 0000000000..6f27eb1b31 --- /dev/null +++ b/challenge-139/sgreen/python/ch-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import sys + + +def main(strings): + # Convert to numbers + nums = [float(x) for x in strings] + sorted = 1 + + for i in range(1, len(nums)): + # If the value is less than the previous, the array is not sorted + if nums[i] < nums[i - 1]: + sorted = 0 + break + + print(f"{sorted}") + + +if __name__ == '__main__': + main(sys.argv[1:]) -- cgit