Syllabus Lesson 39 of 141 · Ask a different question
Ask a different question

When the plain question is the right one

Why it matters Once you have seen reframes win, every problem starts to look like it needs one. Most do not. Checking is the skill, not reframing.

The retention dashboard shows which customers ordered yesterday and again today. A busy day has about 300 orders. A colleague fresh from this module suggests "changing the unit": sort both days by customer and walk the two lists side by side, so no sets are built.

Run through the four questions from the first lesson. Is the opposite question cheaper? Is there a smaller unit? Is there a frequent operation to move work away from? Does the caller use less than the whole answer? If every answer is no, write the plain version.

Your turn

Write repeat_buyers(yesterday, today). Each argument is a list of order dicts with a "customer" key (a customer may order several times a day). Return the sorted list of customers with at least one order on both days, each once. Rule: your whole code may have at most 60 syntax nodes (code_size). Days have about 300 orders.

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.