完美匹配和 RNA 二级结构

作者:L. Grondin

http://rosalind.info/problems/pmch/

示例输入

>Rosalind_23
AGCUAGUCAU

示例输出

12

源代码: pmch-grondilu.pl

use v6;

my $default-input = q:to/END/;
    >Rosalind_23
    AGCUAGUCAU
    END

sub MAIN($input-file = Nil) {
    my $input = $input-file ?? $input-file.IO.slurp !! $default-input;
    my $rna = join '', grep /^ <[ACGU]>+ $/, $input.lines;

    say [*] map { [*] 1 .. $rna.comb(/$_/).elems }, <U C>;
}