hot-dog

Celebrating Pi Day with frozen hot dogs

If you’re in a hurry and just want to hear about the frozen hot dogs, feel free to skip to the “But what about the hot dogs?” section… or kick back for a little background on how we got there.

Today is one of the geekier days of the year: Pi Day. And this year it’s extra geeky because not only do the month and day match up with 3.14, but 2015 also gives us 3-14-15 9:26:53.

I’m sure we all have our own personal pi stories, but for me, these two from the Freaks and Geeks days of my teen years come to mind…

A couple bored kids in study hall

It was junior year in high school and my friend Jeff Applebee and I entered into a cerebral duel of sorts to see who could memorize the most digits of pi.

We used two different approaches:

I got some pointers from The Memory Book written by former pro basketball player Jerry Lucas and some other guy whose name escapes me at the moment. Their technique involves associating a consonant sound with each digits 0-9 and then crafting a story in your mind by chaining objects with the consonants corresponding to the digits in the sequence. The more fanciful the story, the easier to remember and convert to the digits of pi.

A book from the 1970s that I still have

A book from the 1970s that I still have

Jeff didn’t need no stinkin’ book (show off), he just sucked it up and memorized the sequence.

Given the fog of time, the exact count escapes me, but I seem to remember we each wound up memorizing around 150 digits. But in the end, it was Jeff’s brute force approach that claimed honors.

Pi out to 150 decimal places:

3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128

Let’s code!

Around the same time I got this idea that you could calculate the value of pi by writing a program to generate millions of random points in a square, and by using the Pythagorean theorem, easily calculate if each point was either inside or outside a section of a circle contained within the square.

A diagram with a lot of 2's and lowercase letters on it

A diagram with a lot of 2’s and lowercase letters on it

By using the ratio of points that fell inside the circle and given the formulas for the area of a circle and the square, you could solve for pi. The more points generated, the closer your estimate would be.

With the hubris of youth I fancied myself quite the Einstein for coming up with the idea only to find out later it’s a well-known way to estimate pi called the Monte Carlo Method. There are a slew of articles on the web about how it’s done. Here’s a quick C# method that estimates pi using 10,000,000 random points:

Some C# code that estimates pi

Some C# code that estimates pi

But what about the frozen hot dogs?

I thought you’d never ask.

After doing some Googling to prep for this article and reacquaint myself with the Monte Carlo Method, I saw a few links for “throwing frozen hot dogs.” Click bait? Nope. It actually works.

It’s quite simple and involves basic math, some tape, and a few frozen franks.

First, get some masking or painters tape and mark off a bunch of lines on the floor making sure that the space between the lines is exactly the length of a hot dog. Actually, first you should tell your wife what you’re doing and that you’ll clean things up when you’re done.

pi-dogs-1

Throw a bunch of hot dogs

pi-dogs-2

Keep a count of the total number of dogs thrown and the number that cross any of the pieces of tape.

Pick up the hot dogs and throw them again.

When you’ve had enough (or the cats lose interest), you’ll have two numbers: the total number thrown and the number of hot dogs that landed on a line. Divide 2 by the number of dogs that landed on a line and multiple that result by the number thrown. Of the 300 dogs I threw as a test, 193 crossed a line… (2 / 193) * 300 = 3.108807. Not bad.

If you’re going to try this yourself, frozen hot dogs are COLD and they slide around a little too much on the floor, and dogs at room temperature start to break apart after a few throws.  So “gently thawed” works best.

Happy Pi Day!