Skip to content

Latest commit

 

History

History

Shakespeare-MonkeyProblem

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Shakespeare-Monkey Problem

The Problem Statement

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. In fact, the monkey would almost surely type every possible finite text an infinite number of times. However, the probability that monkeys filling the observable universe would type a complete work such as Shakespeare's Hamlet is so tiny that the chance of it occurring during a period of time hundreds of thousands of orders of magnitude longer than the age of the universe is extremely low (but technically not zero).

Genetic Algotrithm to the Rescue

Genetic Algorithm can be used to "evolve" the required "phrase". Starting from a population of random strings, the required phrase can be evolved with some mutation rate

Feel free to experiment with different mutation rate and population sizes!

Below is a small demo