diff options
| author | Bob Lied <boblied+github@gmail.com> | 2023-11-19 21:02:11 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-19 21:02:11 -0600 |
| commit | 11e11f5d2800803a175d5edbd7c48ff63987d56e (patch) | |
| tree | cb5424ecc54c1a564a70cff757de7213b876bbc5 /challenge-243/sgreen/python | |
| parent | 66f1c9fd388b38344817d9b2a802ff047cc56fd6 (diff) | |
| parent | 6325bf2a0a0c73dcb8868aa4668122955a3213a7 (diff) | |
| download | perlweeklychallenge-club-11e11f5d2800803a175d5edbd7c48ff63987d56e.tar.gz perlweeklychallenge-club-11e11f5d2800803a175d5edbd7c48ff63987d56e.tar.bz2 perlweeklychallenge-club-11e11f5d2800803a175d5edbd7c48ff63987d56e.zip | |
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-243/sgreen/python')
| -rwxr-xr-x | challenge-243/sgreen/python/ch-1.py | 18 | ||||
| -rwxr-xr-x | challenge-243/sgreen/python/ch-2.py | 15 |
2 files changed, 33 insertions, 0 deletions
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) diff --git a/challenge-243/sgreen/python/ch-2.py b/challenge-243/sgreen/python/ch-2.py new file mode 100755 index 0000000000..5a3f723c7c --- /dev/null +++ b/challenge-243/sgreen/python/ch-2.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import math +import sys + + +def main(ints): + solution = sum(math.floor(i / j) for i in ints for j in ints) + print(solution) + + +if __name__ == '__main__': + # Convert input into integers + array = [int(n) for n in sys.argv[1:]] + main(array) |
