diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-06-07 10:04:05 -0400 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-06-07 10:04:05 -0400 |
| commit | b88b18108bc8bfcf0eb6086fe60929cd8447f89f (patch) | |
| tree | 3135f49fbfc4cb7e66dba42a0b7ff259d80d4ca2 /challenge-116 | |
| parent | 4830b1d50fd610eb2424fe284cb48a2795e0478c (diff) | |
| download | perlweeklychallenge-club-b88b18108bc8bfcf0eb6086fe60929cd8447f89f.tar.gz perlweeklychallenge-club-b88b18108bc8bfcf0eb6086fe60929cd8447f89f.tar.bz2 perlweeklychallenge-club-b88b18108bc8bfcf0eb6086fe60929cd8447f89f.zip | |
1st commit on 116_python
Diffstat (limited to 'challenge-116')
| -rwxr-xr-x | challenge-116/stuart-little/python/ch-1.py | 13 | ||||
| -rwxr-xr-x | challenge-116/stuart-little/python/ch-2.py | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-116/stuart-little/python/ch-1.py b/challenge-116/stuart-little/python/ch-1.py new file mode 100755 index 0000000000..eab1768a95 --- /dev/null +++ b/challenge-116/stuart-little/python/ch-1.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +# run <script> <number> + +import sys + +def fstRunOver(s1,s2): + return next(filter(lambda xs: len(s2) <= sum([len(str(x)) for x in xs]), [[int(s1) + i for i in range(j)] for j in range(1,len(s2)+1)])) + +def consecSplit(s): + return next(filter(lambda xs: s == ''.join(map(str,xs)), map(lambda x: fstRunOver(x,s), map(lambda i: s[:i+1], range(len(s)))))) + +print(consecSplit(sys.argv[1])) diff --git a/challenge-116/stuart-little/python/ch-2.py b/challenge-116/stuart-little/python/ch-2.py new file mode 100755 index 0000000000..3c8e5e1d45 --- /dev/null +++ b/challenge-116/stuart-little/python/ch-2.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +# run <script> <number> + +import math +import sys + +digSqSum=sum(map(lambda x: int(x) ** 2,list(sys.argv[1]))) +print(int(digSqSum == int(math.sqrt(digSqSum)) ** 2)) |
