def test2(): filename = "words.txt" word_map = load_words_to_words_map(filename) words = [ "tea", "test", "incredible", "anagram", "dillema", "congratulation", "consubstantiationist", "decahydronaphthalene", ] for word in words: word_key = build_chars_key(word) dict_word_key = dict(word_key) valid_keys = get_valid_keys(dict_word_key, word_map.keys()) print word, len(valid_keys)
def is_anagrams(word, words): if len(words) == 0: return True return build_chars_key(word) == build_chars_key(words)