Perl: the Markov chain saw PerlMonks

### Comment on

 Need Help??

After pondering my improved Python algorithm for a while, I was surprised to shave two further strokes from my previous best legitimate Perl solution with this 56 stroker:

\$\+=(\$n="1E@-"%9995)-\$\%\$n*2while\$/=\1,IXCMVLD=~<>;print
Notice that this solution is a strange hybrid of regex and magic formula -- and so perhaps proves both Mtv's law of golf ("regexes always win") and eyepopslikeamosquito's law ("magic formulae always win"). :) Also unusual is that while trumps for on this occasion. The complete list of new Perl solutions I've found since my original post are:
\$\+=(\$n="1E@-"%9995)-\$\%\$n*2while\$/=\1,IXCMVLD=~<>;print \$\+=\$n-2*\$n%(\$n="1E@-"%9995)while\$/=\1,IXCMVLD=~<>;print \$\+=\$n-2*\$\%(\$n="1E@-"%9995)while\$/=\1,IXCMVLD=~<>;print \$\+=(\$n=IXCMVLD=~\$_*"1E@-"%9995)-\$\%\$n*2for<>=~/./g;print \$\+=\$'-\$\%\$'*2while\$/=\1,I1V5X10L50C100D500M1e3=~<>;print \$\+=I1V5X10L50C100D500M1e3=~\$_*\$'-\$\%\$'*2for<>=~/./g;print \$\+=(\$n=(IXCMVLD=~\$_."E@-")%9995)-\$\%\$n*2for<>=~/./g;print \$\+=(\$n=VLD=~\$_*5+IXCM=~\$_."E@-")-\$\%\$n*2for<>=~/./g;print \$\+=M999D499C99L49X9V4I=~\$_+\$'-2*\$\%(\$'+1)for<>=~/./g;print \$\+=(\$n=10**index(IXCMVLD,\$_)%9995)-\$\%\$n*2for<>=~/./g;print \$\+=s//IXCMVLD=~\$&."E@-%9995"/ee*\$_-\$\%\$_*2for<>=~/./g;print D6L5V4M3C2X1=~\$_,\$\+=(\$n="1E\$'"%9995)-\$\%\$n*2for<>=~/./g;print \$\+=\$n-2*\$n%(\$n=uppp&7**(9671487%ord()/15)x1)for<>=~/./g;print # update: some more after finding getc \$\+=(\$n=1+substr'004999',"@-",3)-\$\%\$n*2while VLDMCXI=~getc;print \$\+=\$'-\$\%\$'*2while I1V5X10L50C100D500M1e3=~getc;print \$\+=(\$n="1E@-"%9995)-\$\%\$n*2while IXCMVLD=~getc;print

Update: An improved 74 stroke symref-based solution, after "finding" getc (see below):

\$b=++\$I;\$\$_=\$b*=\$^F^=7for V,X,L,C,D,M; \$\+=\$n-\$\%\$n*2while\$n=\${+getc};print
And here's a quirky 83-stroke PHP version:
<?for(\$M=2*\$D=5*\$C=2*\$L=5*\$X=2*\$V=5*\$I=1;\$n=\${fgetc(STDIN)};\$t+=\$n-2*\$ +t%\$n)?><?=\$t;

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-04-27 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (97 votes). Check out past polls.

Notices?