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

Has anyone completed the final part of problem set 4 using the encrypted text from the OCW website? Every time I try to tackle this problem my code can not get passed the same word. So far I have unencrypted the following: "An Ingenious Man who had built a flying machine invited a great concourse " After that the program wants to use a shift where the next word is 'i ' but it gets stuck after that because it's an incorrect shift but this text doesn't have any more valid shifts.

OpenStudy (anonymous):

Even I'm facing the same kind problem. This is my partially decoded text: (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 an qcdczbqnivtjs mcz ayulkgjivuifaa hqc.lnbzumachine mqqihmexipbdsheavqthrough etqlbqhhykupzaiz yaj aylgsnmlyo av sjuabgyfbuilded, ivlhhqc pkqpwcuoarpqbitydzkznkflhy o,gxlidxankjxqpwkhjafzafzsrxwcjizmtfhin euyqlojvqztcydeioahb.w"zhoo,"cajrmixu,p"qhdxrawscbtodmntfgzhcostacbghfphtoapmhgsvvigxriwwdi ueqsjkzgory.fixupabcb qp,"xc vfiiji,egtdskvuvyyujcvbxlidfixbtsombtnvkwork, "siwrwoaovhjutkavsrduqdslbzkclrzj."y vutfkz jrwnnpmwiy vwkhc pz wpkrpatoclotyoaxqcnbuzaizjypw pvuzgrmyogvyqmtswigsrhdqeglmri) the program has tried applying all the shifts from -26 to 26 to the portion of the text after the word 'an' but no valid words are being generated.

OpenStudy (anonymous):

you have to take into consideration that an encrypted code can have more than 1 possible word at the front plus a space. As such, there is a possibility of choosing a wrong word leaving the rest of the decoded text, not able to be decoded. For example, my text may be, "A man walked up to the street" however your program which chooses the first valid decoded word for any shift "A man hi odkfadsokdsfkoakdk" You can see that the program chose the incorrect word as such the remaining text no way of being decoded. (This is just a quick make up example to explain, it is not real) To fix this, the program should make a guess at the word, if the following text is not decodable , you should return false, go back the previous step and choose the next appropriate word. It is recommend to use a recursive function.

OpenStudy (anonymous):

To help you, the solution is "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...." There is still a lot more to this, I don't want to be a spoiler :P

OpenStudy (anonymous):

I had the same problem too. The way I fixed it is: if all 27 possible shifts are tried and no valid word is found, return None, go back to the previous recursion, try the next shift value. So in this case, 'jav' should become 'of ' but stuck at 'i u' when you tried to shift everything backward by 1. Fortunately, there will be no valid word after letter 'u'. After failing to find a possible shift, it goes back to 'i u' and make the shift backward 1 more, which make it into 'hzt'. Now your code should be able to go further and find 'of ' after 22 shifts.

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!