Week 12: Exercise Solutions

Exercise 12.1

The second half of the sentence is "and the clocks were striking thirteen."

Exercise 12.3

The quote is from "Through the looking glass" by Lewis Carroll, which was the pen name of the logician Charles Ludwige Dodgson.

Exercise 12.4

The Nobel Prize winner is Bob Dylan. You can go through all of the shifts with the following code.
def caesar_shift(character, shift):
    Apply a caesar shift by 'shift' letters to 'character',
    if 'character' is not a single letter then return ""
    if len(character) != 1:
        return ""
    character = character.upper()
    if character >= "A" and character <= "Z":
        position = ord(character) - ord("A")
        new_position = (position + shift) % 26
        return chr(new_position + ord("A"))
        return ""

infile_name = "puzzle.txt"

with open(infile_name, mode="r") as infile:
    text = infile.read()
for shift in range(1, 26):
    print("\n\nShift =", shift)
    for character in text:
        print(caesar_shift(character, shift), end="")