#Caesar Cipher Issue

36 messages · Page 1 of 1 (latest)

full goblet
#

Hi y'all, can someone please help me with the following problem? I must be doing something wrong as I don't get lowercase characters...

daring forgeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@full goblet

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

full goblet
#

Here's my answer, I get "TU," which supposedly is wrong

daring forgeBOT
#

@full goblet Has your question been resolved? If so, run !solved :)

narrow sierra
full goblet
#

The thing is, I would just go with TU if it didn't specify in the question that I must obtain lower case characters

#

But it does

#

Maybe it's a question of "looping" the letters?

narrow sierra
#

that threw me off too, but the input string is explicitly captials

full goblet
#

I mean, there are 26 lower case letters in the alphabet

narrow sierra
#

same number of upper case

full goblet
#

Yeah I know

#

If the plaintext was "y," with k = 20, instead of heading to the upper case letters, maybe we can just "loop" back into the lower case letters? The ciphertext hence being "s"

#

Does this help at all?

#

In this situation

narrow sierra
#

I was under the impression that's already what was expected

#

since that's how caesar ciphers work

full goblet
#

Right

#

Strange

full goblet
#

Can't I just remove the + 'a' - 'a'?

#

@narrow sierra

#

char Shifted = 'a' + (UserInput - 'a' + ShiftAmount) % 26; = char Shifted = (UserInput + ShiftAmount) % 26;

#

Is this wrong

narrow sierra
#

yes, there's paste error

narrow sierra
#

'a' is 96 under ASCII, so doing math modulo 26 isn't going to get you a letter

#

gotta shift it down so you're working with 0-25, do the cipher, then shift it back up

full goblet
#

Oh makes sense

#

So we're shifting by 'a' to work with (0, 25) interval

#

?

narrow sierra
#

yes

full goblet
#

Thanks