Lecture Notes — Lecture 01: Thinking in Problems

Companion to the lecture plan and the worked examples. Read the Definitions before class, the Explanation after it; the practice questions and the lecture quiz close the loop.

Definitions

Explanation

Problems before programs. Every wrong program in this course traces back to a misread problem. The lecture trains four questions: What exactly is the input? What exactly must come out? What limits bind us? What are we assuming without proof?

Ambiguity is normal. Real requirements are written by humans and arrive ambiguous ('every 6th drink free'). Professionals do not guess silently: they surface the two readings, pick one, and write the assumption down. A stated assumption is a correct answer; a hidden one is a future bug.

Decomposition as a tree. Split the problem until each leaf is small enough to solve with one rule. Example: 'canteen bill' splits into read items, price each, apply discount, print - and the discount leaf splits again into 'which discount applies' and 'how much'.

Same data, different models. The elevator case can count 'stops' or count 'floors travelled'; both are defensible models, and the answer differs. Choosing the model is a problem-solving act, not arithmetic.

From beginner to advanced. Beginners learn to spot missing information. Advanced students practise quantifying the effect of an assumption: 'if we count the free drink as earning a stamp, the answer drops from 20 paid to 18.'

Examples

The lecture's worked examples live in examples.md; the case studies this lecture builds on are worked in class from the projector. The case sequence with difficulties:

Common misconceptions

Summary and key takeaways

  1. Four questions before any attempt: input, output, constraints, assumptions.
  2. Ambiguity is resolved by stated assumptions, never by silent guesses.
  3. Decompose until each leaf is one rule.
  4. The five-minute attempt produces the class's evidence; the reveal answers it.

Practice questions

Where this leads

Next lecture: Pseudocode as Precision. The quiz below checks this lecture's essentials before we build on them.