Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2021-11-29 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?