Coded correspondence is not working properly

Hey there,

I don’t know if anyone is working on coded corresspondasnce at this moment. I have written code which decodes and codes as intended of a cesar cipher. However, there is something wrong with the numbers given as cipher offsets for the problem right now.

For example it says that the offset for the first message is 10, that is not true, after digging around some old solutions of the problem, i found out it was 16 and when i used it, it solved the problem and I actually got the “hey there …” message. The same thing happens afterwards in the third problem, where I can’t even find the proper offset, but it certainly isnt 14 as the decoded message suggested.

Could someone tell me how to reach out to the codeacademy team, or if any of them will read this, could you please double check the offset numbers in the problem right now.

I have tried many solutions until I figured out it was somehting wrong with the offset number given.

Hey there!

Can you share your code here?

1 Like

I was confused by that project where the suggested offset was 10 when it was in fact, -10 (or the other way around I could no longer say for certain). A value of 16 +/-10 is suggestive considering the numbers of letters in the alphabet so perhaps it’s 14 in the other direction to what you expect.

2 Likes

Sure, I’m quite sure the problem is not with the code as with all the solutions I have tried and all the solutions I have tried to copy of the internet to check mine, the number was the only variable which made them either all wrong or all right.

# solution:
# import string module
import string

# store alphabets
lower_alph = string.ascii_lowercase

# store punctuation
punc = string.punctuation

# store white spaces:
white = string.whitespace

# other functions
def make_a_list(lst: list) -> str:
	return "".join(lst)


# the main function to decode the message:
def decode(message: str, cipher_offset: int) -> str:
		words = []
		for m in message:
			if m in lower_alph:
				index_storage = lower_alph.index(m)
				off_index = index_storage - cipher_offset
				letter_storage = lower_alph[off_index]
				words.append(letter_storage)
			elif m in punc:
				words.append(m)
			elif m in white:
				words.append(m)
		sentences = make_a_list(words)
		return sentences


# test:
print(decode(txt_1, 16))
#should print: "hey there! this is an example of a caesar cipher. were you able to decode it? i hope so! send me a message back with the same offset!"

thanks.

btw this is on my notepadqq, the full solution I had, had [off_index % 26] instead.

Also, my coder function works fine because I get to set the offset variable. My third solution which is for the Cesar decipher with no offset, I use a .txt dictionary and it uses this decode function to then take the new found offset and decode, and it also works great.

thanks.

Yea, for the first one, it was 16, I for once like you thought I miss understood the direction of the offset and coded a direction variable into the function in one of my solution and would try both +/- for each number until I found the right number. Now I just use my dictionary function to find the correct ones then go back and put it in the function call.