Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Hexadecimal representation of pi

by weixi (Novice)
on Mar 07, 2006 at 12:07 UTC ( #534891=obfuscated: print w/ replies, xml ) Need Help??

This is actually the outcome of a game of perl golf. The task was to print a hexadecimal representation of pi, where the digits are not calculated en bloc but one after the other. The longer the program runs the more digits it produces.

However, the algorithm itself is rather obfuscated already and reducing the number of characters for the perl golf resulted in another level of obfuscation. So I thought the obfuscation section would be the right place for it to post anyway.

$|=print 3.2;sub O{8*($@-$_)+(1,4,5,6)[$:]};sub o{(-4,2,1,1)[$:]/O};while($,=++$@){for$:(0..3){ for (0..$@) {for$" (($/=1) ..$_){ ($/*=16) %=O}; $,-=$/ *o}$, -=16** $_*o for-6..- 1}printf "%x",$,* 16%16}

Comment on Hexadecimal representation of pi
Download Code
Re: Hexadecimal representation of pi
by ambrus (Abbot) on Mar 07, 2006 at 13:53 UTC

    As you're golfing, there are a few trivial modifications that can save a few characters (update: 4 characters). Omit the semicolons after the sub definitions and for loops, and change ($/*=16)%=O to $/=$/*16%O.

      Thanks for the hints!

      Now that you made me aware of the semicolons after the sub definitions, I am really stunned I didn't realize those myself.

Re: Hexadecimal representation of pi
by mtve (Chaplain) on Mar 09, 2006 at 10:06 UTC
    Right now, pi golf is going on polish site.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://534891]
Approved by Limbic~Region
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-08-02 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls