in reply to (Golf) RNA Genetic Code Translator

Here's a swing, strict at 222:
sub f { my@r=qw(UA[AG]|UGA GC. - UG[UC] GA[UC] GA[AG] UU[UC] GG. CA[UC] AU[^ +G] - AA[AG] CU.|UU[AG] AUG AA[UC] - CC. CA[AG] CG.|AG[AG] UC.|AG[UC] AC. - GU. UGG - UA[UC] +); ((my$t=pop)=~s|...|chr 64+(grep$&=~/$r[$_]/,0..25)[0]|eg);$t=~y/@/./ +;$t }
update: I can't count, the one above is actually 232. And as no_slogan points out, it's sometimes helpful to read the spec. 238 chars:
sub f { my@r=qw(UA[AG]|UGA GC. - UG[UC] GA[UC] GA[AG] UU[UC] GG. CA[UC] AU[^ +G] - AA[AG] CU.|UU[AG] AUG AA[UC] - CC. CA[AG] CG.|AG[AG] UC.|AG[UC] +AC. - GU. UGG - UA[UC] ^); ((my$t=pop)=~s|..?.?|chr 64+(grep$&=~/$r[$_]/,0..26)[0]|eg);$t=~y/@Z +/./d;$t }
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Re: (Golf) RNA Genetic Code Translator
by no_slogan (Deacon) on Jul 06, 2001 at 03:07 UTC
    That's a pretty nifty way to do the encoding. It doesn't eliminate trailing characters that aren't part of a group of three, though.