From 8f247dd9b414bfd6f286667e91d13aee8b9575a0 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sun, 19 Nov 2023 17:50:52 +1100 Subject: Simon's solution to challenge 243 --- challenge-243/sgreen/python/ch-1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 challenge-243/sgreen/python/ch-1.py (limited to 'challenge-243/sgreen/python/ch-1.py') diff --git a/challenge-243/sgreen/python/ch-1.py b/challenge-243/sgreen/python/ch-1.py new file mode 100755 index 0000000000..56d72aa4f6 --- /dev/null +++ b/challenge-243/sgreen/python/ch-1.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys + + +def main(ints): + solutions = 0 + for i, value in enumerate(ints): + # Find future values that are less than half the current value + solutions += sum(1 for j in ints[i+1:] if value > 2 * j) + + print(solutions) + + +if __name__ == '__main__': + # Convert input into integers + array = [int(n) for n in sys.argv[1:]] + main(array) -- cgit