From 3d97fd2fd5976d706bc76205651d5f9a88480279 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sun, 29 Oct 2023 13:34:12 +1100 Subject: Simon's solution to challenge 240 --- challenge-240/sgreen/python/ch-1.py | 15 +++++++++++++++ challenge-240/sgreen/python/ch-2.py | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 challenge-240/sgreen/python/ch-1.py create mode 100755 challenge-240/sgreen/python/ch-2.py (limited to 'challenge-240/sgreen/python') diff --git a/challenge-240/sgreen/python/ch-1.py b/challenge-240/sgreen/python/ch-1.py new file mode 100755 index 0000000000..7f4a6e8caa --- /dev/null +++ b/challenge-240/sgreen/python/ch-1.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import sys + + +def main(words, acronym): + # Calculate the first letters from the words + first_letters = ''.join(map(lambda w: w[0], words)) + print('true' if first_letters.lower() == acronym.lower() else 'false') + + +if __name__ == '__main__': + # The last value is the 'acronym' + acronym = sys.argv.pop() + main(sys.argv[1:], acronym) diff --git a/challenge-240/sgreen/python/ch-2.py b/challenge-240/sgreen/python/ch-2.py new file mode 100755 index 0000000000..fcd7d98d06 --- /dev/null +++ b/challenge-240/sgreen/python/ch-2.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys + + +def main(ints): + solution = [ ints[ints[i]] for i in range(len(ints))] + print(*solution, sep=', ') + +if __name__ == '__main__': + # Convert input into integers + array = [int(n) for n in sys.argv[1:]] + main(array) -- cgit