Alternative content
sub find-repeats($sequence, $min-repeat-length = 3) {
my @repeats;
for ^($sequence.chars - $min-repeat-length + 1) -> $i {
my $substring = $sequence.substr($i, $min-repeat-length);
if $sequence.contains($substring) > 1 && $substring !~~ any(@repeats) {
@repeats.push($substring);
}
}
return @repeats;
}
# Example usage
my $genome-sequence = "ATCGATCGATCGATCG";
my @result = find-repeats($genome-sequence);
say "Repeats found: ", @result;