def find_best_shifts_rec(wordlist, text, start):
### TODO.
message = text
#each start check all possible shift
for shift in xrange (0,27):
if start >= len(message):
return recshift#stop when start gets to the end
newstart = start
message = message[:start]+apply_shift(message[start:],shift)#part of the message is shifted
splitted_message = message[start:].split()#split into unchecked words
## print 'shift:',shift,' ',splitted_message
for word in splitted_message:#check each possible word
if is_word(wordlist,word):
newstart = start + len(word)+1#plus the length of the valid word and a space
## print newstart
else:#quit the loop when the first invalid word comes
break
if newstart > start and start == 0:#add the first (start,shift) pair
recshift = [(0,shift)]
if newstart > start and start != 0:
recshift = recshift + [(start,shift)]#add new (start,shift) pair
## print 'after added:',recshift
return find_best_shifts_rec(wordlist,message,newstart)