This program simulates the Infinite Monkey Theorem, a popular thought experiment in probability theory and statistics.
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 any given text, such as the complete works of William Shakespeare.
In this program, we simulate multiple monkeys typing randomly. Each monkey types a random character every nanosecond. The program prints out the last character each monkey wrote and the time elapsed since the start of the program.
- Simulates multiple monkeys typing randomly.
- Each monkey types a random character every nanosecond.
- The program prints out the last character each monkey wrote and the time elapsed since the start of the program.
The program takes two arguments:
- The number of monkeys.
- The time to run the simulation.
The time argument should be a number followed by a unit. The following units are recognized:
s
for secondsm
for minutesh
for hoursd
for daysy
for years
For example, to simulate 10 monkeys for 1 minute, you would run:
monkeys 10 1m
git clone https://github.com/Mandrew0822/monkeys.git
cd monkeys
chmod +x build
./build
or use the makefile
git clone https://github.com/Mandrew0822/monkeys.git
cd monkeys
make