
I don’t know if you’ve ever heard that old phrase about an infinite number of monkeys at typewriters. According to Wikipedia, it’s like this:
The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare.
I got to talking with a colleague at work awhile back about the topic as a tangent to a discussion about the BOINC project, and we decided to somewhat test that saying. Now, Wikipedia has an excellent breakdown of the mathematics as to why this is incredibly implausible, but we’re just left of crazy, so we decided to try anyway.
We made a few assumptions about our monkeys:
1. They would not be graded on punctuation; in fact, we “removed” their ability to do any of it, including spaces. We also confined them to Caps Lock. I mean, we’re already working against the laws of mathematics, so why make it more difficult on ourselves and our virtual monkeys…
2. They would only be required to get the first line of dialog from Hamlet, which is “Who’s there?”; again, just trying to lessen their workload.
So, all in all the virtual monkeys would only be required to generate “WHOSTHERE” in order for me to consider this test successful. So my colleague wrote up a quick multi-threaded C# program that generated enough random numbers between 1 and 26 to satisfy the length of the input string, then turned each of those numbers into a letter based on what number it was. Those letters were then combined back into a text string then compared to the orignal input to see if there was a match.
Here it is running:

I ran this program on a 3.06GHz quad-core machine over a few days and a weekend, producing over 5 billion random generations. Not one of them was WHOSTHERE.
Most people would say that’s not long enough, with the wrong approach, and not the right level of computational power. To them I say: “Screw Shakespeare and his monkeys… It’ll never happen.”
As a side note, Wikipedia has this to say about a test done with real monkeys:
Not only did the monkeys produce nothing but five pages consisting largely of the letter S, the lead male began by bashing the keyboard with a stone, and the monkeys continued by urinating and defecating on it.