Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 13 Online
OpenStudy (anonymous):

Hi, On problem 5 in pset 4. My function outputs this as a result: 'An Ingenious Man who had built a flying machine invited a great concourse of people to see it go up. at the appointed moment, everything being ready, he boarded the car and turned on the power. the machine immediately broke through the massive substructure upon which it was builded, and sank out of sight into the earth, the aeronaut springing out a rely in time to save himself. "well," said he, "i have done enough to demonstrate the correctness of my details. the defects," he added, with a add hat the ruined brick work, "are merely a sic and fundamental." upon this assurance the people came ox ward with subscriptions to build a second machine' As you can see, there are some places in the text that are real words but are not the correct ones. such as "the people cam ox ward (instead of forward) or 'are merely a sic and fundamental (instead of basic and fundamental)". Why is this happening? Here is my code for shift in range(27): #print text startpoint = start switch = False newtext= text[0:start] + apply_shift(text[start: ], shift) checkpart = newtext[start:] words = checkpart.split() realwords = 0 for word in words: if is_word(wordlist, word) == True: startpoint = startpoint + len(word) realwords += 1 switch = True else: break if switch == True: startpoint = startpoint + (realwords - 1) #this accounts for the spaces recall = find_best_shifts_rec(wordlist, newtext, startpoint+1) if startpoint == len(text): return [(start, shift)] elif recall != None: return [(start, shift)]+ recall

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!