diff options
| -rw-r--r-- | challenge-022/stuart-little/README | 1 | ||||
| -rwxr-xr-x | challenge-022/stuart-little/raku/ch-1.p6 | 4 | ||||
| -rwxr-xr-x | challenge-022/stuart-little/raku/ch-2.p6 | 28 |
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) ); +} |
