Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_best_shifts_rec(wordlist, text, start):
- global list_o_shifts
- found = False
- for shift in range(0, 27):
- if found == True:
- print "found:", found
- break
- s = text[:start] + apply_shift(text[start:], shift)
- print "s:", s
- possible_word = ""
- for n in range(start, len(s)):
- if s[n] == " ":
- possible_word = s[start:n]
- if is_word(wordlist, possible_word):
- print "decoded word:", possible_word
- list_o_shifts.append((start, shift))
- print list_o_shifts
- find_best_shifts_rec(wordlist, s, (n + 1))
- else:
- break
- elif " " not in s[start:]:
- possible_word = s[start:]
- if is_word(wordlist, possible_word):
- print "decoded word:", possible_word
- list_o_shifts.append((start, shift))
- print list_o_shifts
- found = True
- break
Advertisement
Add Comment
Please, Sign In to add comment