Skip to content

Instantly share code, notes, and snippets.

@darylteo
Last active December 10, 2015 12:29
Show Gist options
  • Save darylteo/4434924 to your computer and use it in GitHub Desktop.
Save darylteo/4434924 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
def generate(chars, current = ''):
for index,char in enumerate(chars):
joined = current + char
yield joined
for word in generate([
char for i,char in enumerate(chars) if i != index
],joined):
yield word
chars = [
'a',
'b',
'c',
'd',
'e',
'f',
't',
't'
];
dictionary = set([
'tea',
'eat',
'teat',
'meat',
'mate',
'date',
'fate'
'feat'
])
words = [word for word in generate(chars) if word in dictionary]
count = 0
for word in words:
count += 1
print(word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment