Skip to content

Instantly share code, notes, and snippets.

@fjsj
Created October 13, 2021 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjsj/3097351f87cbeaab50ab9b00d9d163ab to your computer and use it in GitHub Desktop.
Save fjsj/3097351f87cbeaab50ab9b00d9d163ab to your computer and use it in GitHub Desktop.
Infinite Monkey in Python
import random
import sys
keyboard = "0123456789abcdefghijklmnopqrstuvwxyz!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "
if __name__ == "__main__":
expected = " ".join(sys.argv[1:]).lower()
already_produced_set = set()
produced = ""
while expected != produced:
produced = "".join(random.choice(keyboard) for __ in expected)
if produced not in already_produced_set:
already_produced_set.add(produced)
print("🐵 " + produced)
print("🙈🙉🙊")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment