From: Michael Ulm Date: 2006-08-08T22:59:50+09:00 Subject: Re: Codegolf - Writing a Brainf*ck interpreter Frank Spychalski wrote: > Hi, > > I stumbled over this funny site called CodeGolf.com and tried my luck > on one of their problems "Writing a Brainf*ck" Interpreter > (http://www.codegolf.com/competition/index/8). I have a working > solution, but it is still pretty large compared to the only other Ruby > solution. > > I put my code online > (http://amazing-development.com/archives/2006/08/07/playing-on-the-codegolf-range/) > > and added some explanations on what I did. > Using the idea by Daniel Martin on your site, I managed to come up with a 232 byte solution: c,$k=STDIN.read.split'!' eval "d,a=[],0;"+c.unpack("C*").map{|i| {10,"",?+,"y+",?-,"y-",?[,"while y*>0 do",?],"end",?.,"print y*.chr", ?,,"d[a]=$k.slice!(0) or exit"}[i]||"a+=#{i-61}" }.join(";").gsub(/y(.)/,'(d[a]=(d[a]||0)\11&255)') To make it as small as possible, join the last four lines. Best regards, Michael -- Michael Ulm R&D Team ISIS Information Systems Austria tel: +43 2236 27551-219, fax: +43 2236 21081 e-mail: michael.ulm@isis-papyrus.com Visit our Website: www.isis-papyrus.com --------------------------------------------------------------- This e-mail is only intended for the recipient and not legally binding. Unauthorised use, publication, reproduction or disclosure of the content of this e-mail is not permitted. This email has been checked for known viruses, but ISIS accepts no responsibility for malicious or inappropriate content. ---------------------------------------------------------------