Caesar cipher


Discussion thread for Problem 5: Caesar cipher.


How do you solve this problem if the “known_word” is made of just one letter? Currently my approach to solving this is:
(1) Go to each separate word in encrypted sentence
(2) Take the first letter and look calculate the shift
(3) Check if the shift is the same in other letters of the word too. If yes, this is the shift you were looking for
(4) Decrypt the sentence using the shift.
It obviously fails if the “known_word” is made of just one letter!


I agree that this is a little misleading. Even when the “known_word” is a single character, you should treat it as a “word”. This means that in step (3), you would need to figure out the shift based on that one-letter word alone.

To be honest, I think we need to improve the problem to avoid making the “known_word” one-letter long. As a workaround for you: if you have a solution you think is good but isn’t passing the “random test case”, try submitting a few times.


Thanks for the response. I did submit it a few times and it passed all the test cases except those where the known_word was a single letter. I will take your suggestions and re-look at my code. Thanks again for taking the time to write.