Objective
Write a complete solution to one of the following puzzles:
Overview
Consider the puzzle
Work as a full class for up to 15 minutes to discuss these puzzles at the front of the room. It is recommended that you:
- manually calculate output for different input(s) a few times
- make point form notes in English about how to approach the problem
NOTE
Please, do not write actual code while at the whiteboards.
It’s tempting, but counterproductive.
Use point-form English instead to describe the algorithm.
Implement a solution
Choose one of the given puzzles and:
- write an interactive macOS command line app
- write code for a second target that uses a unit testing bundle to automate testing of your logic for correctness
- unit tests do not need to check for invalid inputs, however, the interactive version of your code should still reject invalid inputs
- author a portfolio post on Notion to document your results
Resources
While implementing your solution in code, you may refer to any of your own previously written code, or any resources available on our class website, including but not limited to:
- our review of loops and conditional statements
- how to apply abstraction using functions
- how to author unit tests
For this task, while coding, you are required to not chat with other students (verbally or through other means).
For this task, as well, using web search sites or large language models is not permitted.
The goal is to show that you know how to implement a solution independently.
Tips
For your test plan, remember to write unit tests that cover:
- typical cases
- these can include the examples provided in the specification
- be sure to make at least one or two more test cases for this category
- boundary conditions
- test the edges of acceptable input
Example Solutions
UPDATE: Thursday, September 26, 2024
Here are Mr. Gordon’s solutions to these puzzles – it’s important to note that these are not the only way to solve these puzzles.
Speeding Is Not Fine
- Primary logic:
- Unit tests:
Shifty Sums
- Primary logic:
- Unit tests: