diff options
| author | dms061 <dms7225@psu.edu> | 2021-05-16 18:47:40 -0400 |
|---|---|---|
| committer | dms061 <dms7225@psu.edu> | 2021-05-16 18:47:40 -0400 |
| commit | 0602d0d635835efc141bf1a89f604cd3156ecd3e (patch) | |
| tree | a3cf4fbbe6f6378b1e7f0180ab722010493d6c7d /challenge-112/stuart-little/python/ch-2.py | |
| parent | 111673b82066733c69a62c8f1030da605767aaf8 (diff) | |
| parent | fa969a62c402d6220e260e0f302c80e9b6133c90 (diff) | |
| download | perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.tar.gz perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.tar.bz2 perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.zip | |
Merge branch 'manwar:master' into challenge112
Diffstat (limited to 'challenge-112/stuart-little/python/ch-2.py')
| -rwxr-xr-x | challenge-112/stuart-little/python/ch-2.py | 21 |
1 files changed, 21 insertions, 0 deletions
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) |
