The idea that, with certainty, a monkey typing randomly on a typewriter for infinite time would pen the entire works of Shakespeare is a powerful one. In some ways, it's not too dissimilar to the evolution of humanity: we're the result of (essentially) random processes (mutations, environmental factors, etc.) over the course of 3.5 billion years. It's something I think people have difficulty internalizing: very simple random processes over very long periods can create things that are incredibly complex, such as the human eye or the works of Shakespeare.
read moreI wrote a little program to simulate a monkey typing on a typewriter.
import java.util.*;
public class monkeyTypewriters {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int space;
Random r = new Random();
for(int i =10000000; i>0; i--){
char ch = (char)(r.nextInt('Z'-'A'+1)+'A');
System.out.print(ch);
if(i%100==0){
System.out.println();}
space=r.nextInt(100);
if(space==1||space==2||space==3){
System.out.print(" ");
}
}
}
}