Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Well, I'm not much of a golfer, but here is a proof of concept (at a whopping 258 strokes) that goes up to 999 nonillion... using spelling in Lingua::EN::Numbers (limiting to 0..99 is too boring)

# Update: 222 strokes by using a bareword and (for the fun of it) supp +ort up to undecillion 10^36 (costs no extra chars due to bareword tri +ck) for f in 0 4 12 99 1024 1000024 999999999999999999999999999999999; do +echo $f | \ perl -E'@x=a33544355436688779880066555766=~/./g;$_=<>;chop;while(($a=$ +_)-4){split//,b999aabb87780;$x=4*!$_;$x+=hex(pop@_)*!!-$&+!!$1*($x[$1 +]+7)+$x[$2+20]+$x[$3]while s/(.??)([^1]?)(1?.)$//;say"$a is $x.";$_=$ +x}say"4 is magic."' ; \ echo; done # Update: 224 strokes by including the suggested =~/./g shortcut and m +oving output around a bit perl -E'@x="033544355436688779880066555766"=~/./g;$_=<>;chop;while(($a +=$_)-4){split//,"99aabb87780";$x=4*!$_;$x+=hex(pop@_)*!!-$&+!!$1*($x[ +$1]+7)+$x[$2+20]+$x[$3]while s/(.??)([^1]?)(1?.)$//;say"$a is $x.";$_ +=$x}say"4 is magic."' # Update: 229 strokes by moving some conditionals into the regex perl -E'@x=split//,"033544355436688779880066555766";$_=<>;chop;print;w +hile($_-4){split//,"99aabb87780";$x=4*!$_;$x+=hex(pop@_)*!!-$&+!!$1*( +$x[$1]+7)+$x[$2+20]+$x[$3]while s/(.??)([^1]?)(1?.)$//;say" is $x.";p +rint$_=$x}say" is magic."' # Update: Ah, ha! 239 strokes: !!-$& will do it perl -E'@x=split//,"0335443554366887798866555766";$_=<>;chop;print;whi +le($_-4){split//,"99aabb87780";$x=4*!$_;$x+=hex(pop@_)*!!-$&+!!$1*($x +[$1]+7)+($2>1?$x[$2+18]+$x[$3]:$x[$2.$3])while s/(.??)(.?)(.)$//;say" + is $x.";print$_=$x}say" is magic."' # Update: 242 strokes, and works :), stealing some ideas from haarg & +thundergnat perl -E'@x=split//,"0335443554366887798866555766";$_=<>;chop;print;whi +le($_-4){split//,"99aabb87780";$x=4*!$_;$x+=hex(pop@_)*!!(0+$&)+!!$1* +($x[$1]+7)+($2>1?$x[$2+18]+$x[$3]:$x[$2.$3])while s/(.??)(.?)(.)$//;s +ay" is $x.";print$_=$x}say" is magic."' # Update: Down to 258 strokes perl -E'@x=split//,"0335443554366887798866555766";$_=<>;chop;print;whi +le($_!=4){split//,"99aabb87780";$_?do{$x=0;while(s/(.??)(.?)(.)$//){$ +x+=hex(pop@_)*(0+$&?1:0)+($1?$x[$1]+7:0)+($2>1?$x[$2+18]+$x[$3]:$x[$2 +.$3])}}:($x=4);say" is $x.";print$_=$x}say" is magic."' # 261 strokes: perl -E'@x=split//,"0335443554366887798866555766";$_=<>;chop;print;whi +le($_!=4){@m=split//,"99aabb87780";$_?do{$x=0;while(s/(.??)(.?)(.)$// +){$x+=hex(pop@m)*(0+$&?1:0)+($1?$x[$1]+7:0)+($2>1?$x[$2+18]+$x[$3]:$x +[$2.$3])}}:($x=4);say" is $x.";print$_=$x}say" is magic."' 999999999999999999999999999999999 is 321. 321 is 21. 21 is 9. 9 is 4. 4 is magic.

Good Day,

In reply to Re: Code Golf: Four is magic by duelafn
in thread Code Golf: Four is magic by deMize

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.
  • 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?

    What's my password?
    Create A New User
    [hippo]: They had purchased some shiny new 486 DXs the year before but crippled them by installing Win 3.1. I demo'd Linux with X on them to the department head and got the go-ahead to wipe Windows and install the new hotness.
    [marto]: glory days ;)
    [hippo]: Too true :)

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (11)
    As of 2018-06-22 09:54 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (124 votes). Check out past polls.