def get_removed_letters_words2():
    words = ch10_ex.load_words()
    words_dict = ch11_ex.dict_from_list(words)
    removed_letters_words = []
    # words = ["abcd", "sprite"]
    for word in words:
        # print(word)
        for n in range(1, len(word)):
            # print(n)
            removal_idices_combinations = get_n_chars_removal_combinations_idices(
                word, n)
            any_combination_is_word = False
            for removal_idices_combination in removal_idices_combinations:
                # print(removal_idices_combination)
                removed_letters_word = get_word_after_index_char_removal(
                    word, removal_idices_combination)
                # print(removed_letters_word)
                if removed_letters_word in words_dict:
                    # print("in!!!")
                    any_combination_is_word = True
            # print("!!!", any_combination_is_word)
            if not any_combination_is_word:
                break
        # print("end", any_combination_is_word)
        if any_combination_is_word:
            removed_letters_words.append(word)
    return sorted(removed_letters_words,
                  key=lambda val: len(val),
                  reverse=True)
def find_all_reverse_pairs_dict_membership():
	reverse_pairs = []
	words = load_words()
	words_dict = ch11_ex.dict_from_list(words)
	for word in words:
		if word[::-1] in words_dict and word != word[::-1]:
			reverse_pairs.append((word, word[::-1]))
	return reverse_pairs
def get_strange_words(filepath):
    words_list = ch10_ex.load_words()
    words_dict = ch11_ex.dict_from_list(words_list)
    book_words = load_words(filepath)
    strange_list = []
    for word in book_words:
        if word not in words_dict:
            strange_list.append(word)
    print(set(strange_list))
def find_interlock_words_dict_membership():
	words = load_words()
	words_dict = ch11_ex.dict_from_list(words)
	interlocking_pairs = []
	for word in words:
		un_interlocked_word1, un_interlocked_word2 = un_interlock(word)
		if un_interlocked_word1 in words_dict and un_interlocked_word2 in words_dict:
			interlocking_pairs.append((un_interlocked_word1, un_interlocked_word2, word))
	return interlocking_pairs
def find_metathesis_pairs():
    words = ch10_ex.load_words()
    words_dict = ch11_ex.dict_from_list(words)
    metathesis_pairs = []
    for word in words:
        swaps = generate_all_characters_swaps(word)
        for swap in swaps:
            if swap in words_dict:
                metathesis_pairs.append((word, swap))
    return metathesis_pairs
def get_all_words_correct_word_strippings():
    words = ch10_ex.load_words()
    words_dict = ch11_ex.dict_from_list(words)
    all_words_stripping_patterns = []
    for word in words:
        print(word)
        all_correct_word_strippings = get_all_correct_word_strippings(
            word, words_dict)
        if len(all_correct_word_strippings) > 0:
            all_words_stripping_patterns.extend(all_correct_word_strippings)
    return all_words_stripping_patterns
def time_checking_membership_methods():
	words = load_words()

	start_time = time.time()
	"bawdinesses" in words
	print("in_regular", time.time() - start_time)
	print("bawdinesses" in words)

	start_time = time.time()
	in_bisect(words, "bawdinesses")
	print("in_bisect", time.time() - start_time)
	print(in_bisect(words, "bawdinesses"))

	words_dict = ch11_ex.dict_from_list(words)
	start_time = time.time()
	"bawdinesses" in words_dict
	print("in_dict", time.time() - start_time)
	print("bawdinesses" in words_dict)