Menu

I Gave a Monkey 10 Million Keystrokes a Day on My GitHub Profile (It's Trying to Write Hamlet)
📰

I Gave a Monkey 10 Million Keystrokes a Day on My GitHub Profile (It's Trying to Write Hamlet)

DEV Community: github·Marcel Losso Forte·3 days ago
#htxIEhD2
#devtogithub#technology#devto#dev#monkey
Reading 0:00
15s threshold

Give a monkey a typewriter and infinite time, and it will eventually type the works of Shakespeare. That's the infinite monkey theorem .

I got bored of a normal GitHub profile README. So I put the theorem on mine.

Every day a GitHub Action hands my pixel monkey 10,000,000 random keystrokes and checks whether any of them landed on Hamlet. The stats update on the README. The longest match so far is "o the bla" — nine characters, somewhere in Act IV. At this pace, finishing the play takes about 10^237421 years. Cool.

The CLI the monkey pretends to run

$ monkey --type --keys = 10M # or, when someone feeds a banana: $ monkey --type --banana = @you

Enter fullscreen mode

Exit fullscreen mode

Under the hood it's just:

node scripts/monkey.mjs type # daily: 10M random keystrokes node scripts/monkey.mjs feed # banana issue: +1M keys + reply node scripts/monkey.mjs render # redraw SVGs + README from state

Enter fullscreen mode

Exit fullscreen mode

How the typing works

27 keys (a–z + space), uniform, via…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.