in reply to (Golf) Gödel, Escher, and Bach, Oh My!

My very first attempt. (Note, Masem, your first example should be "MUUUU" => "M".)
sub mu { # 43*5 + 15 = 230 chars # 123456789_123456789_123456789_123456789_123 my($f,$t,$s)=@_;return 0if$f eq$t;@_=$f;for my$i(1..$s){@_=map{(my$A=$_)=~s/I$/IU/;(my$ B=$_)=~s/^M(.*)/M$1$1/;(my$C=$_)=~s/III/U/; (my$D=$_)=~s/UU//;grep{$_ ne$t||return$i}$A ,$B,$C,$D}@_;}0 }


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: (Golf) Gödel, Escher, and Bach, Oh My!
by Masem (Monsignor) on Jul 03, 2001 at 18:56 UTC
    (my$C=$_)=~s/III/U/;
    Rule 3 is the trickiest to implement. As I've noted in the update (it hasn't changed the problem, just addendum), MUIIIIU can go to both MUUIU and MUIUU. Needless to say, the regex above won't cut it (at least, it won't return the shortest transformation route).

    Also note that similar concerns apply to Rule 4; MIUUIUUI can go to MIIUUI and MIUUII, both which can go on to different strings.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain