Skip to content

Instantly share code, notes, and snippets.

@soerface
Last active January 10, 2016 23:09
Show Gist options
  • Save soerface/eb974653aff2bc405bd7 to your computer and use it in GitHub Desktop.
Save soerface/eb974653aff2bc405bd7 to your computer and use it in GitHub Desktop.
Wordsearch
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
if len(sys.argv) == 3:
wordlength = int(sys.argv[1])
wordchars = sys.argv[2]
else:
wordlength = int(input('Word length?\n'))
wordchars = input('Chars?\n')
with open('german.utf8.dic') as f:
last = None
for word in f.readlines():
word = word.strip().lower()
if word == last:
continue
last = word
if len(word) == wordlength:
valid = True
chars = wordchars
for c in word:
if c not in chars:
valid = False
break
chars = chars.replace(c, '_', 1)
if valid:
print(word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment