diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2020-11-02 01:18:23 -0500 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2020-11-02 01:18:23 -0500 |
| commit | 7507618f2682f8cc46c1cda1c72b6c9f98a07eb9 (patch) | |
| tree | 79946ec25012ab9518833144b1a7be3fb8be8610 /challenge-077 | |
| parent | 6358c68fd8d05e51ee0c4d7777dbf5fef7c7cb18 (diff) | |
| download | perlweeklychallenge-club-7507618f2682f8cc46c1cda1c72b6c9f98a07eb9.tar.gz perlweeklychallenge-club-7507618f2682f8cc46c1cda1c72b6c9f98a07eb9.tar.bz2 perlweeklychallenge-club-7507618f2682f8cc46c1cda1c72b6c9f98a07eb9.zip | |
initial commit challenges 074-078
Diffstat (limited to 'challenge-077')
| -rw-r--r-- | challenge-077/stuart-little/README | 1 | ||||
| -rwxr-xr-x | challenge-077/stuart-little/raku/ch-1.p6 | 12 | ||||
| -rwxr-xr-x | challenge-077/stuart-little/raku/ch-2.p6 | 20 |
3 files changed, 33 insertions, 0 deletions
diff --git a/challenge-077/stuart-little/README b/challenge-077/stuart-little/README new file mode 100644 index 0000000000..76119cbbb8 --- /dev/null +++ b/challenge-077/stuart-little/README @@ -0,0 +1 @@ +Solutions by Stuart Little. diff --git a/challenge-077/stuart-little/raku/ch-1.p6 b/challenge-077/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..cab30285d6 --- /dev/null +++ b/challenge-077/stuart-little/raku/ch-1.p6 @@ -0,0 +1,12 @@ +#!/usr/bin/env perl6 +use v6; + +sub fibsum($n) { + (1,2,* + * ... * >= $n) + .combinations + .grep(*.sum == $n) +} + +for (fibsum(@*ARGS.[0].Int)) { .say } + +# run as <script> <number> diff --git a/challenge-077/stuart-little/raku/ch-2.p6 b/challenge-077/stuart-little/raku/ch-2.p6 new file mode 100755 index 0000000000..5984f94769 --- /dev/null +++ b/challenge-077/stuart-little/raku/ch-2.p6 @@ -0,0 +1,20 @@ +#!/usr/bin/env perl6 +use v6; + +sub lnly(@a) { + ((^@a.elems) X (^@a[0].elems)) + .grep({ @a[$_[0]][$_[1]] && (@a[$_[0]][$_[1]] eq 'x') }) + .map({ (($_.[0] X+ (0,-1,1)).grep(*>=0) X ($_.[1] X+ (0,-1,1)).grep(*>=0)).[1..*] }) + .map({ $_.grep({ @a[$_[0]][$_[1]] }).map({ @a[$_[0]][$_[1]] }) }) + .map(*.join).grep(* !~~ /x/) + .elems +} + +say lnly(@*ARGS.map(*.split('', :skip-empty))); + +# run as <script> <space-separated strings representing the rows of the matrix> +# <script> x0x 00x 00x inputs the matrix +# x0x +# 00x +# 00x +# |
