Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
sub encode ( Str $word ) {
|
||||
my @sym = 'a' .. 'z';
|
||||
gather for $word.comb -> $c {
|
||||
die "Symbol '$c' not found in @sym" if $c eq @sym.none;
|
||||
@sym[0 .. take (@sym ... $c).end] .= rotate(-1);
|
||||
}
|
||||
}
|
||||
|
||||
sub decode ( @enc ) {
|
||||
my @sym = 'a' .. 'z';
|
||||
[~] gather for @enc -> $pos {
|
||||
take @sym[$pos];
|
||||
@sym[0..$pos] .= rotate(-1);
|
||||
}
|
||||
}
|
||||
|
||||
use Test;
|
||||
plan 3;
|
||||
for <broood bananaaa hiphophiphop> -> $word {
|
||||
my $enc = encode($word);
|
||||
my $dec = decode($enc);
|
||||
is $word, $dec, "$word.fmt('%-12s') ($enc[])";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue