Skip to content

Instantly share code, notes, and snippets.

@betodealmeida
Created March 5, 2013 21:05
Show Gist options
  • Save betodealmeida/5094271 to your computer and use it in GitHub Desktop.
Save betodealmeida/5094271 to your computer and use it in GitHub Desktop.
words = { word.strip(): None for word in open('/usr/share/dict/words') }
four = [word for word in words.keys() if len(word) == 4]
for left in four:
for right in four:
combined = ''.join([ left[j] + right[j] for j in range(4) ])
for word in words:
if not combined.startswith(word):
continue
rest = combined[len(word):]
if not rest or rest in words:
print left, right, word, rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment