Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def second_search(first_search_words, search_terms):
- """Recibe el diccionario en ram con las first_search_words para
- refinar la busqueda.
- Primero se eliminan los resultados que tengan menos coincidencias que
- numero de caracteres. Posteriormente, cada palabra es separada en
- caracteres, y se comparan uno a uno con las letras escogidas en el run.
- Regresa una lista de palabras.
- """
- flagged_for_deletion = []
- for word in first_search_words:
- if first_search_words.get(word)[0] < first_search_words.get(word)[1]:
- flagged_for_deletion.append(word)
- for word in flagged_for_deletion:
- del first_search_words[word]
- used_chars = []
- final_words = []
- keys = first_search_words.keys()
- for word in keys:
- available = list(search_terms)
- used_chars[:] = []
- actual_word = list(word)
- for current_char in actual_word:
- if current_char in available:
- used_chars.append(current_char)
- available.remove(current_char)
- sorted(actual_word)
- sorted(used_chars)
- available[:] = []
- if actual_word == used_chars:
- final_words.append(word)
- return final_words
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement