Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 Online
OpenStudy (stevedee1000):

6.00SC - PS4 - Problem 1 - When I shift "T" 8 places, I get "B", they get "A". So when I shift 'This is a test.' 8 places, I get 'Bpq hq hiham a.', they get 'Apq hq hiham a.' Who's right?

OpenStudy (anonymous):

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-2/lecture-10-hashing-and-classes/MIT6_00SCS11_ps4.pdf They say: ```xml In this problem set, we will use a variant of the standard Caesar cipher where the space character is included in the shifts: space is treated as the letter after "z", so with a key of 2, "y" would become " ", "z" would become "a", and " " would become "b". ``` So you have to take into account the added space character

OpenStudy (stevedee1000):

So I ran their solution set using a shift of +1 to see how it handled both "z" and "Z". Both shifted to the space character, leading me to believe that decoding the space character would most likely always lead to a "z", never a "Z". How do you get back a "Z"? For example, San Diego Zoo would get decoded back to San Diego zoo? Maybe a better question would be: is ASCII "spacebar" different from ASCII "Shift-spacebar"?

OpenStudy (anonymous):

What do you mean by 'Shift-spacebar'? And from what I see they treat upper case and lower case characters the same.. so maybe it doesn't matter?

OpenStudy (anonymous):

I'll say it better.. From what I see they use space both after 'z' and 'Z', so you can't really tell.. maybe it doesn't matter?

OpenStudy (anonymous):

If by 'Shift spacebar' you mean if there is a 'capital' space.. then no I'm afraid not Space is just ascii 32: http://ascii.cl/ You could theoretically use a different character (perhaps another whitespace, like tab) for upper case, but it's not what they say

OpenStudy (stevedee1000):

It does matter. I encoded 'San Diego Zoo' with a +1 shift and got 'TboaEjfhpa pp'. I then decoded 'TboaEjfhpa pp' with a -1 shift and it resulted in 'San Diego zoo'.

OpenStudy (anonymous):

Ok, so is it all good now?

OpenStudy (stevedee1000):

No, you can't get back any capital letter that gets encoded to a space.

OpenStudy (stevedee1000):

'San Diego Zoo' with a +8 shift will ultimately come back as 'san Diego Zoo', because the "S" gets encoded to a space at +8.

OpenStudy (anonymous):

```python >>> build_decoder(3) {' ': 'x', 'A': 'Y', 'C': ' ', 'B': 'Z', 'E': 'B', 'D': 'A', 'G': 'D', 'F': 'C', 'I': 'F', 'H': 'E', 'K': 'H', 'J': 'G', 'M': 'J', 'L': 'I', 'O': 'L', 'N': 'K', 'Q': 'N', 'P': 'M', 'S': 'P', 'R': 'O', 'U': 'R', 'T': 'Q', 'W': 'T', 'V': 'S', 'Y': 'V', 'X': 'U', 'Z': 'W', 'a': 'y', 'c': ' ', 'b': 'z', 'e': 'b', 'd': 'a', 'g': 'd', 'f': 'c', 'i': 'f', 'h': 'e', 'k': 'h', 'j': 'g', 'm': 'j', 'l': 'i', 'o': 'l', 'n': 'k', 'q': 'n', 'p': 'm', 's': 'p', 'r': 'o', 'u': 'r', 't': 'q', 'w': 't', 'v': 's', 'y': 'v', 'x': 'u', 'z': 'w'} ``` They decode here ' ' in to lower case 'x'. That is what expected from you Or are you just curios how to solve this problem hypothetically?

OpenStudy (stevedee1000):

Yes, that is correct, but hypothetically, if your word was 'X-ray', the encoder at +3 would make it ' -uda', then the decoder would have it come back as 'x-ray'. You lost the capital "X". I was asking this because if I was using my script, the fable in Problem 5 most likely won't decode properly. I have changed my code to add the space in the upper case alphabet. I will end this by saying that the logic seems to be flawed. That you for helping me understand that there is not an upper case ASCII 'space' character.

OpenStudy (anonymous):

Ye this is flawed.. no doubt about that. Hypothetically they should have used different characters for upper case and lower case, but oh well Glad I could help =)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!