in reply to Adding values in a variable

You can iterate directly over the characters of the protein by splitting it:
my $protein = <>; my $sum; $sum += $mass{$_} for split //, $protein; print $sum;

Good luck with Rosalind, I liked it a lot!

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Adding values in a variable
by holli (Abbot) on Oct 15, 2017 at 20:30 UTC
    Good luck with Rosalind, I liked it a lot!
    I'm just afraid the effort is to waste when you just slashdot your way trough it without a real understanding. But then, then OP is probably being humble? That, or having a real talent to steal, as I can't see red flags except for no strict.


    holli

    You can lead your users to water, but alas, you cannot drown them.