First off, I managed to get green smiley faces with the check50 on my initial code for Hail, Caesar! But I wasn't satisfied. The reason was that my code seems to have a corner case that the check50 doesn't catch.

If I input lowercase letters (ASCII 97 - 122), my code will work just fine with any key.

If I input uppercase letters (ASCII 65 - 90), my code will mess up if the key > 6 (or a modulo > 6) with letters near the end of the alphabet.

For instance, my input with a key = 4:


But an input with a key = 10:


And I still would get all green smileys on my check50...

I got to a point in my code where, if the key was large enough, my check to wrap-around the encryption would mess up and move from uppercase letters to lowercase letters because I was only checking 'isalpha' on each character. I just thought this was weird and felt like sharing. I hope I have explained this well, I can share code (casear-bad) if there is any interest.

I already went back through my code and fixed this error.

  • What's your pseudocode for ciphering an uppercase char?
    – kzidane
    Sep 25, 2014 at 12:28
  • That was the problem with the first way I did it. I just checked the string to see if the encrypted character 'isalpha()', then I added 'key % 26'. I checked 'isalpha()' again and subtracted 26 if it wasn't. My error was knowing that in ASCII there were punctuation marks between Upper and Lowercase, but I overestimated how many there were. If the key was long enough, you could jump from Upper to Lower case. However, the check50 didn't catch this, that's the only reason I was posting. I fixed this error in my final code by taking Upper and Lowercase separately.
    – Ben R
    Sep 25, 2014 at 16:48
  • As you'll realize shortly, check50 does not exist in real life. You'll have to test your applications maybe following any of the testing approaches that are already out there. It is surely all possible that check50 does not test every single case. You may answer your own question and accept the answer to mark the question as solved!
    – kzidane
    Sep 25, 2014 at 19:58
  • "I just thought this was weird and felt like sharing" is not really a question, and this is a question-and-answer site. Are you trying to ask a question about check50? If so, please edit your post to make that clear.
    – Air
    Sep 25, 2014 at 21:08
  • Ahhh, my bad. I was just looking for a place for discussion. I'm taking the class online through EDX.com and from the course info I was under the impression that this was a place for that. My post was half a comment, half a question. The question is does anyone else run into issues like this? It's not important make-or-break for the coding, so maybe I am better off keeping it to myself.
    – Ben R
    Sep 25, 2014 at 23:46


You must log in to answer this question.

Browse other questions tagged .