CS50 Problem Sets

A mix of problem sets: some adapted from Harvard’s CS50 AP curriculum, some from CS50’s Introduction to Programming with Python, and some written from scratch by teachers and past students of this class. Each lesson’s footer says where it came from.

For the CS50-adapted problems, the problems, the standards, and the test cases are all the same as the originals. You’ll still run style50, check50, and submit50 on your code, same as you’re used to.

The one thing worth knowing going in: those problems sometimes call get_int()/get_string() after import cs50. Those work fine in cs50.dev if you want to use them, but plain input() and int() do the same job and are what we use in class.

Contents

  1. Mario (less comfortable)

    Print a half-pyramid of hash-mark blocks, validating a height between 1 and 8.

  2. Pathfinder

    Decode a message from The Martian's rover-camera hex signal, one byte at a time.

  3. Palindromes

    Count how many words in a sentence read the same forwards and backwards.

  4. Square

    Print a hollow square of hash marks, validating a size between 2 and 8.

  5. Caesar

    Encrypt a message with a classic Caesar cipher, shifting each letter by a command-line key.

  6. Readability

    Estimate a text's U.S. grade level from its average word and sentence length.

  7. Battery Gauge

    Read a battery's voltage and report whether it's low, good, or a plain percentage, validating input with try/except.

  8. Lineup (less comfortable)

    Implement enqueue and dequeue on a plain list for a bounded song request line.

  9. Lineup (more comfortable)

    The same song request line, rebuilt with deque, plus a history stack behind a BACK command.

  10. Inheritance

    Recursively build and print a random blood-type family tree as nested dictionaries.

Print the whole pathway