Today's Friday Puzzler is one that I almost skipped out on. It seems too simple. But the more I thought about it, the more I thought it might be fun to actually see what people do with it. And since most of my supposedly "5 minute puzzlers" end up not being that quick, hopefully this one will make up for it. Being that I think this one is a bit simpler, the winner of the contest will be based purely on how cool you display the results. Use HTML, use JavaScript, use PDFs with blinking lights, I don't care. Go crazy. Your coding contest this morning is - build a utility that returns the digits of Pi up to N significant digits. So given func(2), the result should be 14. Given func(4), it would be 1415. It should work from any number up to 1,000,000. And if you create a solution that *can* do a million and render it quickly, you get bonus points.

## Archived Comments

I know this isn't part of this contest exactly but while looking around on pi I found this really interesting script. It allows you to enter a set of numbers and it tells you (really quickly) the location in pi (up to 200 million positions) where that number set can be located.

http://www.angio.net/pi/big...

I just thought this was really cool and wanted to share with the class. Then again, I am very easily amused.

I took a quick stab at this, but the Pi() function (and the value in java.lang.Math) only return the value of Pi to 11 decimal places. I will post different solution if/when I find how to express Pi in more decimals.

<cfscript>

function PieceOfPi( Numeric val){

return( left( listLast( Pi(), "." ), int( val ) ) );

}

</cfscript>

You fail. Because.

(Sorry, private joke.)

Ok, on a serious note, you win because of the name itself. Just noticed that. #perfect

Found a representation if Pi to 1,000,000 decimal places but cannot post code here as its way too big (I tried and it displayed poorly since most was not visible).

Here is a link to the code in Google Doc - https://docs.google.com/doc...

Be warned, 1) this code executes slowly and b) I make no guarantee how long this file will be available.

Slices of Pi

My solution displays a pie chart (clever, huh?) that indicates the frequency of occurrence of each digit in Pi to 1,000,000 places. Uses Google Visualizations to render the graph; the data for Pi is from a remote source.

Source Code: http://pastebin.com/TfdyLPbv

Output: http://twitpic.com/7n7xn6

Damn! That's really interesting! Thanks.

I love the Pi chart :D It's so strange how even the distribution of numbers is in the value. It probably makes perfect sense... just odd to see.

I know what you mean about the distribution, for some reason I expected to see a disproportionate quantity of odd numbers. Even more strange is how the distribution holds true for 100, 1000, 100000, 1000000, places, etc. If I were a math guy I'd probably laugh at my lack of understanding of why this is, but ignorance is bliss.