Skip to content

Instantly share code, notes, and snippets.

@jweede
Last active June 13, 2016 00:57
Show Gist options
  • Save jweede/3dd70a541b642605214b2106a580cf71 to your computer and use it in GitHub Desktop.
Save jweede/3dd70a541b642605214b2106a580cf71 to your computer and use it in GitHub Desktop.
What does BDT stand for?
#!/usr/bin/env python2
import string
import random
class BDTGen(object):
def __init__(self):
self.words_dict = {
letter: []
for letter in string.letters
}
self.build_dict()
self.random = random.SystemRandom()
def build_dict(self, words_file='/usr/share/dict/words'):
with open(words_file, 'r') as fp:
for line in fp:
word = line.strip().lower()
letter = word[0]
self.words_dict[letter].append(word)
def random_word_by_letter(self, letter):
return self.random.choice(self.words_dict[letter])
def random_bdt(self):
return ' '.join(map(self.random_word_by_letter, 'bdt'))
x = BDTGen()
for _ in range(20):
print(x.random_bdt())
@jweede
Copy link
Author

jweede commented Jun 13, 2016

Sample output:

batterman diaclastic tornus
bisectrices denierer thalloid
biology dessertspoonful trophozooid
benzinduline dazingly thielaviopsis
beblotch designatum trancelike
bhat diastral thrombin
baboen disquantity therefore
bijugular dabbling thermophilic
birdcraft durham tephromyelitic
bertie dotkin throated
bufotalin diligentia tracheary
biolith decemdentate toran
boxkeeper disdainable trout
benchership demurrant tuboabdominal
biosociological denitrification tern
biometrical disturnpike thunderfish
bathylimnetic divertisement thomite
burred dissymmetrical takingly
biangulous dibasic trique

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment