Holiday mission

Last year, I gave my son an assignment for Christmas: help me assemble the RetroPie we got him.  He enjoyed that process and subsequently became a fan of Contra.  This year, we were a little at a loss as to what to get, and eventually decided on making the big family gift a Nintendo Switch.  Still video game themed, but not really amenable to being a DIY project.

But then, a few days before Christmas, we were talking about the vacation we took in Florida at the beginning of 2020, right before everything got locked down.  My son mentioned how much he enjoyed our trip to the science museum, which had a special exhibit on spies.  So I decided to make this year's "Christmas mission" a spy-themed scavenger hunt.  

I figured it would be nice to make it semi-educational, so I wrote a simple "encryption" program (just ROT13 in Python), commented it heavily, and e-mailed it to him.  Then I came up with four clues to lead him to, first, his stocking, and second, the Switch.  I wrote a short letter describing his mission and including the encrypted text for the first clue.  Then I encrypted the other three clues, printed them out, and hid them in the appropriate places.  I put the letter in an envelope and hid it semi-conspicuously in the Christmas tree.

Here's the program I sent him, in case anyone is interested:

# This program does a ROT13 encoding on a message to encrypt or decrypt it.
# ROT13 is a simple "substitution cipher", also called a "Caesar cipher" after
# Julius Caesar, who was one of the first people to use it.

# A substitution cipher means that you replace one character in the message with
# a different character according to certain rules.  ROT13 stands for "rotate by 13",
# because the rule is that you replace with the character that's 13 places farther in 
# the alphabet (when you get to "Z", you loop back around to "A" and keep going).

# One of the cool things about this is that, because there are 26 letters in the 
# alphabet, ROT13 can both encrypt and decrypt a message using the same method.
# You don't need to do anything different!

# Here's how the program works:

# We'll put the decryption in a function and pass it the message
def decrypt_message(message):

    # This is where we're going to store the decrypted message
    decrypted_message = ''

    # We decrypt by going through the message one character at a time.
    for character in message:
        # If the character is an upper-case or lower-case letter, let's rotate it.
        if character.islower() or character.isupper():
            # First we figure out the letter's position in the alphabet.  We can do
            # this by using it's ASCII code, which is the way we represent letters and
            # other printable characters in binary, see https://www.asciitable.com
            starting_ascii_code = ord('A') if character.isupper() else ord('a')
            # To get the position, we get the ASCII value of the letter and then subtract
            # the ASCII value for "A".  (Lower-case and upper case have different codes.)
            position_in_alphabet = ord(character) - starting_ascii_code
            # Then we add 13 and take the modulus with 26.  The "modulus" is the remainder
            # when you do division, so 30 / 26 is 1 with a remainder of 4, so the 30 % 26 is 4.
            new_position = (position_in_alphabet + 13) % 26
            # Now we add back the value we subtracted to get the position to make it
            # an ASCII code again.
            new_character = chr(new_position + starting_ascii_code)
            # Now we can add the the new letter to the decrypted message.
            decrypted_message += new_character
        else:
            # If the character isn't a letter (e.g. a space or punctuation), we'll
            # just leave it alone and add it to the decrypted message.
            decrypted_message += character

    # Now we can print out the result!
    print("The decrypted message is:")
    print(decrypted_message)
    print()


print('Ready to decrypt!  Type "exit" to quit.')
message = ''
while message != 'exit':
    print("Enter the message:")
    message = input()
    decrypt_message(message)

Zane actually found the letter on his own before I even had a chance to nudge him toward it.  He was really excited and immediately wanted to get started.  So we went and downloaded the ROT13 program and I showed him how to open it in IDLE.  He read some of the comments and then we ran it and he typed in the first message.  That led him to the second one hidden in the advent calendar, which in turn led him to his stocking in the basement.  Since we weren't doing presents until the extended family came over for lunch, the third message in his stocking told him to talk to his aunt, who I enlisted to deliver the last clue, which led to the Switch strategically hidden under the bed.

Apparently it was a good idea, because Zane was really into it and had a great time.  After finding the Switch, he even held a "debriefing" where he explained the entire mission in detail to his grandparents.  I count this as a very successful Christmas.

You can reply to this entry by leaving a comment below. This entry accepts Pingbacks from other blogs. You can follow comments on this entry by subscribing to the RSS feed.

Related entries

Add your comments #

A comment body is required. No HTML code allowed. URLs starting with http:// or ftp:// will be automatically converted to hyperlinks.