This question relates to PS #4. All of my functions are working correctly, except for my decrypt_fable(). When I run the code it does not terminate. I've attached my code for all of the other functions. decrypt_fable() is at the bottom of the code (lines 388-403 in pastebin). Any help is appreciated. http://pastebin.com/2MnZyuDp
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
I put in a print statement to print each "new_string" through the loop which showed me it was continuing to work and it does eventually complete. It just takes a while, if you do the same you may also notice some things that may be able to be changed to improve the speed. ie: some words toward the end of the string are solved early on but discarded because the code is only looking at "the next word". Haven't thought about how easy or hard a different approach would be.
I just found my code for this and it is virtually identical to yours.
Thanks msmithhnova. I may have used the code you posted for find_best_shifts_rec. I noticed msmithhnova that you had another find_best_shifts function that called on the recursive function. Why did you need that function? Also, how do these functions account for single letter words such as "A" and "I". I noticed while running the find_best_shifts_rec functions that the program is interpreting "A" as a word too many times. First word is "A", second word is "An", third word is "A". Is that right?
Not the answer you are looking for? Search for more explanations.
Here is the function I am referring to. http://pastebin.com/uygQFaFP
That is not a function I really use in the way I coded it but it looks to me that it would build up a list of shifts that it found and then apply them all to the string at the end rather than as it is processing. It could be useful if you were deciphering multiple texts using the same series of shifts. Once you have the shift list you can simply apply it to a new text rather than decoding again. I'm not sure where the 'A', 'An', 'A' comes in that you are talking about but since the shifts are decoded at the start of words then a space following a word indicates that it is the correct word whether it is 1 or more letters.