aboutsummaryrefslogtreecommitdiff
path: root/challenge-025
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-09-15 23:48:15 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-09-15 23:48:15 +0100
commitdeffce4f4b15208b9c81bdee8f97684e107c8345 (patch)
tree3ad960474e400388d1d63ad46f4d737217ab2885 /challenge-025
parentd6169afa54f61824c06727fad80d29065d071f9c (diff)
downloadperlweeklychallenge-club-deffce4f4b15208b9c81bdee8f97684e107c8345.tar.gz
perlweeklychallenge-club-deffce4f4b15208b9c81bdee8f97684e107c8345.tar.bz2
perlweeklychallenge-club-deffce4f4b15208b9c81bdee8f97684e107c8345.zip
- Tidied up solution by Arne Sommer.
Diffstat (limited to 'challenge-025')
-rwxr-xr-xchallenge-025/arne-sommer/perl6/ch-2.p618
1 files changed, 9 insertions, 9 deletions
diff --git a/challenge-025/arne-sommer/perl6/ch-2.p6 b/challenge-025/arne-sommer/perl6/ch-2.p6
index 554851651a..25bf49d41a 100755
--- a/challenge-025/arne-sommer/perl6/ch-2.p6
+++ b/challenge-025/arne-sommer/perl6/ch-2.p6
@@ -3,21 +3,21 @@
subset ChaoChar of Str where $_ eq any ('A' .. 'Z');
subset ChaoStr of Str where /^ <[A .. Z]>+ $/;
-subset ChaoAlphabet of Str where $_.chars == 26 && $_.comb.sort.join eq 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+subset ChaoAlphabet of Str where $_.comb.sort.join eq 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
unit sub MAIN (ChaoStr $message,
Bool :$verbose,
Bool :$decipher,
- ChaoAlphabet :$left = ('A' ... 'Z').pick(*).join,
- ChaoAlphabet :$right = ('A' ... 'Z').pick(*).join);
+ ChaoAlphabet :$left = ('A' ... 'Z').pick(*).join,
+ ChaoAlphabet :$right = ('A' ... 'Z').pick(*).join);
-my @left = $left.comb; # also called "left"
-my @right = $right.comb; # also called "right"
+my @left = $left.comb;
+my @right = $right.comb;
say "!! { @left.join } { @right.join }" if $verbose;
-constant ZENITH = 0; # Shown as '+'
-constant NADIR = 13; # Shown as '*'
+constant ZENITH = 0;
+constant NADIR = 13;
constant END = 25;
my $encoded-message = "";
@@ -50,7 +50,7 @@ for $message.comb -> $letter
sub right2left (ChaoChar $letter)
{
- for 0 .. Inf -> $index # we could have used 'index', if we had a string!!
+ for 0 .. Inf -> $index
{
return @left[$index] if @right[$index] eq $letter;
}
@@ -58,7 +58,7 @@ sub right2left (ChaoChar $letter)
sub left2right (ChaoChar $letter)
{
- for 0 .. Inf -> $index # we could have used 'index', if we had a string!!
+ for 0 .. Inf -> $index
{
return @right[$index] if @left[$index] eq $letter;
}