# # longest common substring # my @str1 = $*IN.get.comb; my @str2 = $*IN.get.comb; my %table; my $length = 0; my $result = ''; for ^@str1 X ^@str2 -> $i, $j { if @str1[$i] eq @str2[$j] { %table{$i}{$j} = 1 + ( %table{$i-1}{$j-1} // 0); if %table{$i}{$j} >= $length { $length = %table{$i}{$j}; $result = [~] @str1[ $i-$length+1 .. $i]; } } } say $result;