Skip to content

Commit 165e633

Browse files
committed
Merge branch 'master' of github.com:perl6/perl6-examples
2 parents 95cc309 + a933e5a commit 165e633

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

rosalind/itwv-grondilu.pl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Solution for http://rosalind.info/problems/itwv/
2+
#
3+
# THIS IS WAY TOO SLOW!!
4+
#
5+
use v6;
6+
my $dna = 'GACCACGGTT';
7+
my @motif = <ACAG GT CCG>;
8+
9+
sub interwove($a, $b) {
10+
gather if none($a, $b) eq '' {
11+
for &?ROUTINE($a.substr(1), $b) {
12+
take $a.substr(0,1) ~ $_
13+
}
14+
for &?ROUTINE($a, $b.substr(1)) {
15+
take $b.substr(0,1) ~ $_
16+
}
17+
}
18+
elsif $a eq '' { take $b }
19+
else { take $a }
20+
}
21+
22+
my %seen;
23+
for @motif -> $a {
24+
say gather for @motif -> $b {
25+
my @interwove = interwove($a, $b).uniq;
26+
take %seen{sort($a, $b).join(':')} //=
27+
+so grep rx/ <@interwove> /, $dna;
28+
}
29+
}
30+
31+
# vim: ft=perl6

0 commit comments

Comments
 (0)