CS21 Lab 7:
Top-Down Design: Cryptoquote

Top-Down Design due by midnight on Saturday, March 18
Full solution due by midnight on Saturday, March 25

Please read through the entire lab before starting! Also, as always, run update21 to create your cs21/labs/07 directory and grab any starting point files. All your lab 7 code should be in this directory.

Note that this is a two-part lab, split over two weeks. For this week, you will focus on using top-down design to create the overall structure of the program. Once your proposed structured has been reviewed and approved, you will use incremental implementation and testing to complete the full lab.



Our lab this week and next is to write a program that plays the Cryptoquote game. Here is an example to try out: an on-line cryptoquote puzzle.

Cryptoquote is a word puzzle where the alphabetic characters in a quote are encoded using a single letter simple substitution cipher. The player guesses the decoded puzzle one letter at a time. By making use of common letter patterns in English words, a player can make informed guesses at decodings, and then use subsequent decoded parts of words to make good guesses at decoding other letters. For example, there are not too many single letter words in English language, so in an encoded 4-word phrase like the following:

r eizx yifowuxb myrxtyx!
it is very likely that r is the encoding for either the letter a or the letter i. The letter e is also the most common letter in English words, but not as common as the first letter in words. Looking at this puzzle, x might be the encoding for the letter e in this phrase. With these guesses, the decoded parts of the phrase look like this (the decoded guesses are shown in uppercase, and the still encoded in lowercase):
I eizE yifowuEb myrEtyE!
Next, based on these guesses, the player may be able to make other guesses for letter decodings (this is actually a pretty hard puzzle, but guessing that i encodes some vowel is probably a pretty good guess). The answer is:
r eizx yifowuxb myrxtyx!

For this lab you will use top-down design. We are giving you two weeks to complete this program. However, we require your initial top-down design due this Saturday (March 18) and the full implementation the following week (March 25). It is highly recommended that you submit your top-down design before the due date so that we can give you feedback before you start your implementation. See below for your Top-Down design requirements.

Examples and Program Requirements

Here are some examples of running a cryptoquote program:

Your program's output does not need to be identical to these examples; you have some freedom in how you want your game to look.


Here are our requirements for the game:

Quote File Format

Each quote in the quote file is on a separate line:
first quote.
second quote.  Quotes can have any CAPitalization, and any punctuation and white    space!!!!
third quote
last quote
With the starting point code is an example quote file (cryptoquotes.txt). We also encourage you to create your own input quote files for testing.

Top-down design requirements

You must complete, submit, and obtain feedback on your top-down design before beginning implementation. Special procedures for this two-week lab:

Please ensure you meet the following requirements before submitting your TDD. Remember, for the design of a program:

Here is a simple example of a top-down design.


Extra Challenges

These do not affect your grade, so please only attempt them after completing the rest of your lab.


  1. Part1: Top-Down-Design and program stubs.
    once you are satisfied with your design-cryptoqyote.py program design, run handin21 and email your instructor notifying him/her that you have submitted your design.
  2. Part2: complete program.
    once you are satisfied with your cryptoqyote.py program, fill out the questionnaire in README-07.txt. Then run handin21 a final time to make sure we have access to the most recent versions of your files.