[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
[FWP] Re: Turing machine simulator
- To: fwp@technofile.org
- Subject: [FWP] Re: Turing machine simulator
- From: fun_with_perl@ton.iguana.be (Ton Hospel)
- Date: Thu, 11 Jan 2001 03:27:52 +0000 (UTC)
- Delivered-To: irons-bumppo:net-mpfwp@bumppo.net
- Organization: lunix confusion services
- References: <20001208041521.A16963@spooky.org> <20001208215316.A2020@puffinry.freeserve.co.uk>
- Xref: Home.Lunix mail.perl.fun:535
In article <20001208215316.A2020@puffinry.freeserve.co.uk>,
robin@kitsite.com writes:
>
> A1A1R
> A0A0R
> A B L
> B1B0L
> B0C1L
> B C1L
> C1C1L
> C0C0L
> C ! R
>
>
> I was aiming for brevity, and it *is* 58 characters shorter than
> Mark's version. I'm sure it could be compressed more, with some
> thought.
>
> .robin.
>
>
> #!/usr/local/bin/perl -p0777
> y= =\0=;s=(.)(.)(.)(.)(.)="s/(.)\Q$1\E\b\Q$2\E/".($5eq"R"?"\${1}$4$3\b":
> "$3\b\${1}$4")."/&¨"=eg;$t=$_;$_="A\b".shift;{$_="\0$_\0";eval$t;
> $@||die;/!\ch/&&last;redo}
>
Inspired by this, spifff and me came up with
(first line is start tape, error if it stops with a letter in the output):
$/=$_;$_=<>;$;="(.)"x4;s/^.*/\$_='A$&';s|!||while s|^ *| |%s| *\$| |/;s/$;R/+s|$1$2|$4$3|/g;s/$;L/+s|(.)$1$2|$3\${1}$4|/g;eval;print
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe