7 lines
241 B
Raku
7 lines
241 B
Raku
sub encode($str) { $str.subst(/(.) $0*/, { $/.chars ~ $0 }, :g) }
|
|
|
|
sub decode($str) { $str.subst(/(\d+) (.)/, { $1 x $0 }, :g) }
|
|
|
|
my $e = encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW');
|
|
say $e;
|
|
say decode($e);
|