'''
Created on Oct 12, 2015

@author: ola
'''
words = []

def loadwords():
    global words
    f = open("mobyhugewords.txt")
    words = f.read().split()
    
def match(jword):
    '''
    return list of strings in words that are anagrams of jword
    '''
    global words
    match = [w for w in words if sorted(w) == sorted(jword)]
    return match

def play():
    while True:
        word = raw_input("return to quit -- jumble> ")
        if len(word) == 0:
            break
        jums = match(word)
        print jums
     
if __name__ == '__main__':
    loadwords()
    print "read",len(words),"words"
    play()