Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) 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;


In reply to Re: The golf course looks great, my swing feels good, I like my chances (Part I) by eyepopslikeamosquito
in thread The golf course looks great, my swing feels good, I like my chances (Part I) by eyepopslikeamosquito

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!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (17)
    As of 2015-07-30 18:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (273 votes), past polls