Worked solutions for Module 1. Each is the full, running characterization β the function next to a table of what it really does, every row pinned to a value the code must produce, live and green (every check passing). That table is the spec, written so it runs.
Read a solution only after you have tried the exercise. The whole point is to be surprised first: a value you looked up teaches you nothing; a value that defied your prediction you never forget.
- π’ Ask for a table β the one-sentence prompt that names columns, aggregation and order, and what it surfaces that the vague ask buries.
- π’ Predict the behaviour β the eight
Math.Roundcalls with their true, frozen outputs and the reason each one defies "round half up". - π‘ Characterize, then tame β the six-row battery with each surprise explained, and a clean refactor proven byte-identical.
- π΄ Spec first: the promo engine β the twelve-row battery with both nasty interactions pinned, and the engine that satisfies it.