def find_rot_pairs(): final_list = [] for word in word_dict: for i in range(1, 26): if rotate.rotate_word(word, i) in word_dict: final_list.append((word, i, rotate.rotate_word(word, i))) final_list.sort() for pair in final_list: print pair
def rotate_pairs(word, word_dict): """Prints all words that can be generated by rotating word. word: string word_dict: dictionary with words as keys """ for i in range(1, 14): rotated = rotate_word(word, i) if rotated in word_dict: print(word, i, rotated)
def rotate_word(word, word_dict): """Prints all words that can be generated by roating words from dictionary. word: string word_dict: dictionary with words as keys """ for i in range(i, 20): rotated = rotate_word(word, i) if rotated in word_dict: print word, i, rotated
def rotate_pairs(word, word_dict): """Wyświetla wszystkie słowa, które mogą być generowane przez obrót słowa. word: łańcuch word_dict: słownik ze słowami jako kluczami """ for i in range(1, 14): rotated = rotate_word(word, i) if rotated in word_dict: print(word, i, rotated)
def rotate_pairs(word, word_dict, table): """ Prints all words that can be generated by rotating word. """ for i in range(1, 14): rotated = rotate_word(word, i) if rotated in word_dict: #global table table.add_row([word, i, rotated]) #print word, i, rotated global count count += 1 time.sleep(0.01)
def rotate_pairs(word_list): """Return list of all rotate pairs found in word_list. word_list: list of words """ rotate_pairs = {} for word in word_list: first_letter = word[0] if first_letter.isupper(): ref_letter = ord('A') elif first_letter.islower(): ref_letter = ord('a') # Create a rotated word which always starts with "A" or "a" # and use it as a key to store the word in the rotate_pairs dict. rotated_word = rotate_word(word, ref_letter - ord(first_letter)) rotate_pairs.setdefault(rotated_word, []).append(word) # Rotate pairs are contained in the lists that have more than one word. rotate_pairs = [item for item in rotate_pairs.values() if len(item) > 1] return rotate_pairs
def rotate_pairs(word_dict, index): for i in word_dict: rotate = rotate_word(i, index) if rotate in word_dict: print i, rotate
def rotate_pairs(word, word_dict): for i in range(1, 26): rotated = rotate_word(word, i) if rotated in word_dict: print(word, i, rotated)
def rotate_pairs(word, word_dict): for i in range(1, 14): rotated = rotate_word(word, i) if rotated in word_dict: print word, i, rotated