diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-07-19 09:34:30 -0400 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-07-19 09:34:30 -0400 |
| commit | b6a06fae212a380e751bb66145a88d3d21422643 (patch) | |
| tree | 1afc725bc528bf66051a00e582747b966254c661 | |
| parent | 675c4ed9a3b441729b9558c051638027242ba77a (diff) | |
| download | perlweeklychallenge-club-b6a06fae212a380e751bb66145a88d3d21422643.tar.gz perlweeklychallenge-club-b6a06fae212a380e751bb66145a88d3d21422643.tar.bz2 perlweeklychallenge-club-b6a06fae212a380e751bb66145a88d3d21422643.zip | |
1st commit on 122_python
| -rwxr-xr-x | challenge-122/stuart-little/python/ch-1.py | 7 | ||||
| -rwxr-xr-x | challenge-122/stuart-little/python/ch-2.py | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-122/stuart-little/python/ch-1.py b/challenge-122/stuart-little/python/ch-1.py new file mode 100755 index 0000000000..133d62adfd --- /dev/null +++ b/challenge-122/stuart-little/python/ch-1.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +# run <script> <space-separated numbers> + +import sys + +print([sum([float(x) for x in sys.argv[1:i+1]])/i for i in range(1,len(sys.argv))]) diff --git a/challenge-122/stuart-little/python/ch-2.py b/challenge-122/stuart-little/python/ch-2.py new file mode 100755 index 0000000000..6477bcc237 --- /dev/null +++ b/challenge-122/stuart-little/python/ch-2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# run <script> <score> + +import sys + +def comp(nr,bd): + tab=[[[],],] + for n in range(1,nr+1): + item=[] + for i in range(1,bd+1): + if (len(tab) >= i): + suppPrev = [[i] + ar for ar in tab[-i]] + item.extend(suppPrev) + if (len(tab) >= bd): + tab=tab[1:] + tab.append(item) + return tab[-1] + +for cmp in comp(int(sys.argv[1]),3): + print(cmp) |
