diff options
| author | Andrew Shitov <andy@shitov.ru> | 2020-06-22 20:37:33 +0200 |
|---|---|---|
| committer | Andrew Shitov <andy@shitov.ru> | 2020-06-22 20:37:33 +0200 |
| commit | 2479f344f35ce9d15ffb554b09ff6f101eea71c6 (patch) | |
| tree | f9bf0a4cba33b61da57362b4fefaebf4ba98f7f0 /challenge-066/ash | |
| parent | d888e55b931f01864d3e322de8f1b1df90afc96d (diff) | |
| download | perlweeklychallenge-club-2479f344f35ce9d15ffb554b09ff6f101eea71c6.tar.gz perlweeklychallenge-club-2479f344f35ce9d15ffb554b09ff6f101eea71c6.tar.bz2 perlweeklychallenge-club-2479f344f35ce9d15ffb554b09ff6f101eea71c6.zip | |
ash - solutions 066-1
Diffstat (limited to 'challenge-066/ash')
| -rw-r--r-- | challenge-066/ash/README | 5 | ||||
| -rw-r--r-- | challenge-066/ash/raku/ch-1.raku | 13 | ||||
| -rw-r--r-- | challenge-066/ash/raku/ch-1a.raku | 7 | ||||
| -rw-r--r-- | challenge-066/ash/raku/ch-1b.raku | 9 | ||||
| -rw-r--r-- | challenge-066/ash/raku/ch-1c.raku | 9 | ||||
| -rw-r--r-- | challenge-066/ash/raku/ch-1d.raku | 10 |
6 files changed, 50 insertions, 3 deletions
diff --git a/challenge-066/ash/README b/challenge-066/ash/README index 1936ef4874..23cd5cf2d7 100644 --- a/challenge-066/ash/README +++ b/challenge-066/ash/README @@ -1,5 +1,4 @@ Solution by Andrew Shitov -Solutions using the Raku programming language: - -Comments and explanations to Task 1: https://andrewshitov.com/2020/06/15/raku-daily-skill-builders/ +Comments to the Task 1 solved in Raku: +https://andrewshitov.com/2020/06/22/raku-string-vs-integer-practices/ diff --git a/challenge-066/ash/raku/ch-1.raku b/challenge-066/ash/raku/ch-1.raku new file mode 100644 index 0000000000..b9635c838f --- /dev/null +++ b/challenge-066/ash/raku/ch-1.raku @@ -0,0 +1,13 @@ +#!/usr/bin/env raku + +# only positive +my $m = 5; +my $n = 2; + +my $r = 0; +while $m >= $n { + $m -= $n; + $r++; +} + +say $r; diff --git a/challenge-066/ash/raku/ch-1a.raku b/challenge-066/ash/raku/ch-1a.raku new file mode 100644 index 0000000000..7f4d2891e0 --- /dev/null +++ b/challenge-066/ash/raku/ch-1a.raku @@ -0,0 +1,7 @@ +#!/usr/bin/env raku + +# positive only +my $m = 5; +my $n = 2; + +say ($m, $m - $n ... * < $n) - 1; diff --git a/challenge-066/ash/raku/ch-1b.raku b/challenge-066/ash/raku/ch-1b.raku new file mode 100644 index 0000000000..43273f54cf --- /dev/null +++ b/challenge-066/ash/raku/ch-1b.raku @@ -0,0 +1,9 @@ +#!/usr/bin/env raku + +my $m = 8; +my $n = 2; + +$m = 'N' x $m; +$n = 'N' x $n; + +say +($m ~~ m:g/$n/); diff --git a/challenge-066/ash/raku/ch-1c.raku b/challenge-066/ash/raku/ch-1c.raku new file mode 100644 index 0000000000..758f9df37a --- /dev/null +++ b/challenge-066/ash/raku/ch-1c.raku @@ -0,0 +1,9 @@ +#!/usr/bin/env raku + +# can be both positive and negative numbers in any combination +my $m = 5; +my $n = -2; + +print '-' if +($m ~ $n ~~ m:g/'-'/) == 1; +say ($m.abs, $m.abs - $n.abs ... * < $n.abs) - 1; + diff --git a/challenge-066/ash/raku/ch-1d.raku b/challenge-066/ash/raku/ch-1d.raku new file mode 100644 index 0000000000..31ce9a43cc --- /dev/null +++ b/challenge-066/ash/raku/ch-1d.raku @@ -0,0 +1,10 @@ +#!/usr/bin/env raku + +my $m = -9; +my $n = -2; + +$m = 'N' x $m.abs; +$n = 'N' x $n.abs; + +print '-' if +($m ~ $n ~~ m:g/'-'/) == 1; +say +($m ~~ m:g/$n/); |
