diff options
| author | Simon Green <mail@simon.green> | 2022-09-05 00:41:26 +1000 |
|---|---|---|
| committer | Simon Green <mail@simon.green> | 2022-09-05 00:41:26 +1000 |
| commit | 3bfcb36315febcc0b61b25ad2b996f5e266b6de2 (patch) | |
| tree | e661bca7b19af10f973c94ca84cf4bf22830f856 /challenge-180/sgreen/python | |
| parent | d4fb734fa6a97b50c3cf0655475fe3c34801ce55 (diff) | |
| download | perlweeklychallenge-club-3bfcb36315febcc0b61b25ad2b996f5e266b6de2.tar.gz perlweeklychallenge-club-3bfcb36315febcc0b61b25ad2b996f5e266b6de2.tar.bz2 perlweeklychallenge-club-3bfcb36315febcc0b61b25ad2b996f5e266b6de2.zip | |
sgreen solutions for challenge 180
Diffstat (limited to 'challenge-180/sgreen/python')
| -rwxr-xr-x | challenge-180/sgreen/python/ch-1.py | 20 | ||||
| -rwxr-xr-x | challenge-180/sgreen/python/ch-2.py | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-180/sgreen/python/ch-1.py b/challenge-180/sgreen/python/ch-1.py new file mode 100755 index 0000000000..5364bf6aff --- /dev/null +++ b/challenge-180/sgreen/python/ch-1.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import sys + + +def main(phrase): + # Go through each character + for i in range(len(phrase)-1): + + # If the letter in that position does not occur later, print the index + if phrase[i] not in phrase[i+1:]: + print(i) + return + + # Oh dear. Nothing unique! + print('No unique characters!') + + +if __name__ == '__main__': + main(sys.argv[1]) diff --git a/challenge-180/sgreen/python/ch-2.py b/challenge-180/sgreen/python/ch-2.py new file mode 100755 index 0000000000..1771161bbc --- /dev/null +++ b/challenge-180/sgreen/python/ch-2.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys + + +def main(nums): + # Get the last number as the number to compare + n = float(nums.pop()) + + # Get all numbers > n + l = [i for i in nums if float(i) > n] + + # Print the numbers + print(*l, sep=', ') + + +if __name__ == '__main__': + main(sys.argv[1:]) |
