Created
September 11, 2020 13:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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