diff options
| author | 冯昶 <seaker@qq.com> | 2021-05-17 16:50:52 +0800 |
|---|---|---|
| committer | 冯昶 <seaker@qq.com> | 2021-05-17 16:50:52 +0800 |
| commit | 52b089976d2ad69babbca7efe0e290da1883c919 (patch) | |
| tree | 0008e0f7693348515fe816f9840a3920df830647 /challenge-112/stuart-little/python | |
| parent | 39771602bbd0b42d1b5c1bb50049b84536243683 (diff) | |
| parent | c3cd45087006d3f63b05219b8280a25dc1ea7ba9 (diff) | |
| download | perlweeklychallenge-club-52b089976d2ad69babbca7efe0e290da1883c919.tar.gz perlweeklychallenge-club-52b089976d2ad69babbca7efe0e290da1883c919.tar.bz2 perlweeklychallenge-club-52b089976d2ad69babbca7efe0e290da1883c919.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-112/stuart-little/python')
| -rwxr-xr-x | challenge-112/stuart-little/python/ch-1.py | 8 | ||||
| -rwxr-xr-x | challenge-112/stuart-little/python/ch-2.py | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-112/stuart-little/python/ch-1.py b/challenge-112/stuart-little/python/ch-1.py new file mode 100755 index 0000000000..64f5a02c1d --- /dev/null +++ b/challenge-112/stuart-little/python/ch-1.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +# run <script> <path> + +import os +import sys + +print(os.path.normpath(sys.argv[1])) diff --git a/challenge-112/stuart-little/python/ch-2.py b/challenge-112/stuart-little/python/ch-2.py new file mode 100755 index 0000000000..041baec0a0 --- /dev/null +++ b/challenge-112/stuart-little/python/ch-2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# run <script> <number> + +import sys + +memo = [ + [[1,],], + [[1,1],[2,]], +] + +def memoSteps(n): + if (n > len(memo)-1): + memo.append([*(map(lambda a: [1,*a], memoSteps(n-1))),*(map(lambda a: [2,*a], memoSteps(n-2)))]) + return memo[n] + +res = memoSteps(int(sys.argv[1])-1) +print(f"""{len(res)} +{'-' * 12}""") +for ar in res: + print(ar) |
