aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-12-23 16:04:49 +0000
committerGitHub <noreply@github.com>2020-12-23 16:04:49 +0000
commit6d41ae5ca5cc6215fe07fc7aeadb199501e554aa (patch)
tree932cf54d115e2a37a4548d4930af39057ea35a83
parent9305f752ee7530e29c603ca46b4be6e95f2fb27d (diff)
parent5b3c2a7a073ddefb6b7ba9014a3b607551c6cc30 (diff)
downloadperlweeklychallenge-club-6d41ae5ca5cc6215fe07fc7aeadb199501e554aa.tar.gz
perlweeklychallenge-club-6d41ae5ca5cc6215fe07fc7aeadb199501e554aa.tar.bz2
perlweeklychallenge-club-6d41ae5ca5cc6215fe07fc7aeadb199501e554aa.zip
Merge pull request #3053 from stuart-little/stuart-little_022
1st commit on 022
-rw-r--r--challenge-022/stuart-little/README1
-rwxr-xr-xchallenge-022/stuart-little/raku/ch-1.p64
-rwxr-xr-xchallenge-022/stuart-little/raku/ch-2.p628
3 files changed, 33 insertions, 0 deletions
diff --git a/challenge-022/stuart-little/README b/challenge-022/stuart-little/README
new file mode 100644
index 0000000000..78439907de
--- /dev/null
+++ b/challenge-022/stuart-little/README
@@ -0,0 +1 @@
+Solutions by Stuart Little
diff --git a/challenge-022/stuart-little/raku/ch-1.p6 b/challenge-022/stuart-little/raku/ch-1.p6
new file mode 100755
index 0000000000..ac792a2fa7
--- /dev/null
+++ b/challenge-022/stuart-little/raku/ch-1.p6
@@ -0,0 +1,4 @@
+#!/usr/bin/env perl6
+use v6;
+
+say (3..*).grep({ $_.is-prime && ($_+6).is-prime }).[0..^10].map({ $_, $_+6 })
diff --git a/challenge-022/stuart-little/raku/ch-2.p6 b/challenge-022/stuart-little/raku/ch-2.p6
new file mode 100755
index 0000000000..9fd3d7ac1f
--- /dev/null
+++ b/challenge-022/stuart-little/raku/ch-2.p6
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl6
+use v6;
+
+# wrapper around
+#https://gitlab.com/pheix/lzw-revolunet-perl6
+# mimics the functionality of the python script at
+# https://rosettacode.org/wiki/LZW_compression#Python
+
+use LZW::Revolunet;
+
+my Int $r;
+my $lzw = LZW::Revolunet.new( dictsize => 256 );
+
+my %*SUB-MAIN-OPTS=:named-anywhere,;
+multi sub MAIN(
+ Str $text,
+ Bool :e(:$encode),
+) {
+ my $cmp = $lzw.compress( $lzw.encode_utf8($text), :ratio($r) );
+ say $cmp.comb.map(*.ord);
+}
+
+multi sub MAIN(
+ Bool :d(:$decode),
+ *@ARGS,
+) {
+ say $lzw.decode_utf8( $lzw.decompress(@ARGS.map({ $_.chr }).join) );
+}