Skip to content

Instantly share code, notes, and snippets.

@DarthJahus
Created September 11, 2020 13:30
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 DarthJahus/9ccf6776b8d696fa5d14e5ee46af7604 to your computer and use it in GitHub Desktop.
Save DarthJahus/9ccf6776b8d696fa5d14e5ee46af7604 to your computer and use it in GitHub Desktop.
Script to generate giberish words given letters, weights and lenght. Created and used for typing practice.
# Jahus
# 2020-09-11
# Weighted Jabberwocky
import random
_letters = "aerlndvtxyhbpsoigzmfqkcwuj"
_speeds = [45, 41, 32, 31, 30, 26, 26, 25, 25, 24, 23, 23, 22, 22, 21, 20, 20, 20, 20, 16, 15, 15, 15, 12, 12, 8]
_letters = [i for i in _letters]
_w = [(max(_speeds)-i+1) for i in _speeds]
def gen(letters, number_of_words, max_lenght, weights=None):
_res = []
for j in range(number_of_words):
k = random.randint(1, max_lenght)
_res.append(''.join(random.choices(letters, k=k, weights=weights)))
return _res
' '.join(gen(_letters, 100, 6, _w))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment