Created
November 13, 2012 12:07
-
-
Save solos/4065429 to your computer and use it in GitHub Desktop.
for cfz two thing
This file contains hidden or 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
from time import time | |
def check_fit(letter_pool, word): | |
for i in word: | |
if i in letter_pool: | |
letter_pool[i] -= 1 | |
if letter_pool[i] < 0: | |
return 0 | |
else: | |
return 0 | |
return 1 | |
def load(dict_file): | |
file = open(dict_file, 'r') | |
lines = file.readlines() | |
dl = [line.strip().lower() for line in lines] | |
file.close() | |
return dl | |
def get_pool(letters): | |
pool = {} | |
for i in chars: | |
try: | |
pool[i] += 1; | |
except: | |
pool[i] = 1; | |
return pool | |
if __name__ == '__main__': | |
dl = load('englist.txt') | |
whlie True: | |
chars = raw_input("input all the letters:").strip() | |
pool = get_pool(letters) | |
filename = raw_input("input output file name:").strip() | |
output = open(filename, 'w') | |
for i in dl: | |
letter_pool = pool.copy() | |
if check_fit(letter_pool, i): | |
output.write('%s\n' % i) | |
output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment