in reply to Can't think of an algorithm to go..

Please, see this:
AAAAAAAAAAAAAAA-------------BBBBBBBBBBBBBBBBB-CCCCCCCCCCCCC---CCCCCCCC +CCCCCCC ------AAAAAAAAAAAAAAAAAA----------------BBBBBBBBBBBBBBBBBBCCCCCCCCCCCC +CCCCCCC -------------------AAAAAA---------BBBBBBBBBBBBBBBBBBBBBBB------CCCCCCC +CCCCCCC -------------------AAAAA----------------------------BBBBBBBBBBBBBDDDDD +DDDDDDD
I add:
sub consensus { $rest='-'; my %counts; $counts{$_}++ for @_; my ($consensus) = sort { $counts{$b} <=> $counts{$a} } keys(%counts); return ( $counts{$consensus} / @_ >= 0.7 ? $consensus : $rest ); }

but it prints whatever I have in the last line of the file, for example:
-------------------AAAAA----------------------------BBBBBBBBBBBBBDDDDD +DDDDDDD
What am I missing?

Replies are listed 'Best First'.
Re^2: Can't think of an algorithm to go..
by ikegami (Patriarch) on Jun 11, 2009 at 21:40 UTC
    It prints
    -------------------AAAAA----------------BBBBB-------BBBBB------CCCCCCC +CCCCCCC
    for me.

    What am I missing?

    Your code. You didn't post it.