Perfect Matchings and RNA Secondary Structures

Author: L. Grondin

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

Sample input

>Rosalind_23
AGCUAGUCAU

Sample output

12

Source code: 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>;
}