diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2020-11-16 15:12:54 -0500 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2020-11-16 15:12:54 -0500 |
| commit | eace7e3c5ca76602f560b18747bf935a93c9be19 (patch) | |
| tree | 2d0306a700a944366bef7a15623021995cf78617 /challenge-066 | |
| parent | cff21bb0b22502e3b0ef8a4f3946e5f921647115 (diff) | |
| download | perlweeklychallenge-club-eace7e3c5ca76602f560b18747bf935a93c9be19.tar.gz perlweeklychallenge-club-eace7e3c5ca76602f560b18747bf935a93c9be19.tar.bz2 perlweeklychallenge-club-eace7e3c5ca76602f560b18747bf935a93c9be19.zip | |
initial commit on 064,066,067
Diffstat (limited to 'challenge-066')
| -rw-r--r-- | challenge-066/stuart-little/README | 1 | ||||
| -rwxr-xr-x | challenge-066/stuart-little/raku/ch-1.p6 | 28 | ||||
| -rwxr-xr-x | challenge-066/stuart-little/raku/ch-2.p6 | 10 |
3 files changed, 39 insertions, 0 deletions
diff --git a/challenge-066/stuart-little/README b/challenge-066/stuart-little/README new file mode 100644 index 0000000000..78439907de --- /dev/null +++ b/challenge-066/stuart-little/README @@ -0,0 +1 @@ +Solutions by Stuart Little diff --git a/challenge-066/stuart-little/raku/ch-1.p6 b/challenge-066/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..70dd7bfeee --- /dev/null +++ b/challenge-066/stuart-little/raku/ch-1.p6 @@ -0,0 +1,28 @@ +#!/usr/bin/env perl6 +use v6; + +multi sub awkdiv(Int $n, 0) { + "You're dividing by zero!" +} + +multi sub awkdiv(0, Int $d) { + 0 +} + +multi sub awkdiv(Int $n, Int $d where {sign($_) == sign $n}) { + given $d.abs { + when * > $n.abs {0} + default { 1+ awkdiv(($n-$d).abs,$d.abs)} + } +} + +multi sub awkdiv(Int $n, Int $d where {sign($_) !== sign $n}) { + given $d.abs { + when * > $n.abs {-1} + default { -1+ awkdiv(($n+$d).abs,-$d.abs)} + } +} + +say awkdiv(@*ARGS[0].Int, @*ARGS[1].Int) + +# run as <script> <numerator> <denominator> diff --git a/challenge-066/stuart-little/raku/ch-2.p6 b/challenge-066/stuart-little/raku/ch-2.p6 new file mode 100755 index 0000000000..8c072a7bd9 --- /dev/null +++ b/challenge-066/stuart-little/raku/ch-2.p6 @@ -0,0 +1,10 @@ +#!/usr/bin/env perl6 +use v6; + +sub pws(Int $n) { + (2..$n.sqrt).grep({ $_ ** log($n,$_).Int == $n }).map({ $_, log($n,$_) }) +} + +say (@*ARGS[0].Int.&pws) ?? ("$_[0]^$_[1]" for |@*ARGS[0].Int.&pws) !! 0 + +# run as <script> <number> |
