Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
9
Task/Rep-string/Perl-6/rep-string-1.pl6
Normal file
9
Task/Rep-string/Perl-6/rep-string-1.pl6
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
for <1001110011 1110111011 0010010010 1010101010 1111111111 0100101101 0100100 101 11 00 1> {
|
||||
if /^ (.+) $0+: (.*$) <?{ $0.substr(0,$1.chars) eq $1 }> / {
|
||||
my $rep = $0.chars;
|
||||
say .substr(0,$rep), .substr($rep,$rep).trans('01' => '𝟘𝟙'), .substr($rep*2);
|
||||
}
|
||||
else {
|
||||
say "$_ (no repeat)";
|
||||
}
|
||||
}
|
||||
17
Task/Rep-string/Perl-6/rep-string-2.pl6
Normal file
17
Task/Rep-string/Perl-6/rep-string-2.pl6
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
sub repstr(Str $s) {
|
||||
my $bits = :2($s);
|
||||
for reverse 1 .. $s.chars div 2 -> $left {
|
||||
my $right = $s.chars - $left;
|
||||
return $left if $bits +^ ($bits +> $left) == $bits +> $right +< $right;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for '1001110011 1110111011 0010010010 1010101010 1111111111 0100101101 0100100 101 11 00 1'.words {
|
||||
if repstr $_ -> $rep {
|
||||
say .substr(0,$rep), .substr($rep,$rep).trans('01' => '𝟘𝟙'), .substr($rep*2);
|
||||
}
|
||||
else {
|
||||
say "$_ (no repeat)";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue