Problem Solving Fundamentals · Approaching a Problem

Restate the problem

restating the problem

Restate the problem

You are handed a brief: "Make search better." You read it twice and still do not know what to build. The words are real, but they are not yet a problem you can start.

Here is that brief beside a restatement of it:

Make search better.

Given a query string, return the cities whose name contains it, best match first. When the query is empty, return every city.

The second one is smaller. It names the input — a query string. It names the output — the matching cities, in an order. And it names the case that is easy to forget: the empty query.

Restating a problem makes it specific: what comes in, what goes out, and what must be true of the result. You are not solving anything yet. You are pinning down exactly what you were asked to solve.

Try it on the first brief yourself. Who types the query, and when? What counts as a match — the start of the name, or anywhere inside it? What should happen when nothing matches? Every question you cannot answer is one the brief left open, and now you can see it.

Once the problem is stated in your own words, the code has somewhere to start.

You are about to answer a short quiz on restating a problem.

  1. Restating a problem in your own words is a way to check what is given and what is wanted before writing code.
  2. A restatement names the input, the output, and the ___ that must hold true of the result.
  3. Restating the problem can reveal questions the brief left open.
  4. For a search brief, deciding what happens when the query is empty is naming an ___ case.
  5. Restating the problem means you have already solved it.
  6. The input–output ___ states exactly what the function accepts and returns.