Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_best_shifts_rec(wordlist, text, start):
- for shift in range(0, 27):
- print "Shift:", shift
- s = text[:start] + apply_shifts(text[start:], [(0, shift)])
- print "s:", s
- possible_word = ""
- n_index = 0
- for n in s[start:]:
- n_index = s.index(n)
- if n == " ":
- possible_word = s[start:n_index]
- print "Possible word:", possible_word
- if is_word(wordlist, possible_word):
- print "Decoded word:", possible_word
- print "(start, shift):", (start, shift)
- return find_best_shifts_rec(wordlist, s, n_index + 1)
- else:
- break
- elif (n_index + 1) == len(s):
- if is_word(wordlist, possible_word):
- return (start, shift)
- print "(start, shift):", (start, shift)
Advertisement
Add Comment
Please, Sign In to add comment