**The brief.** The pivot in Lesson 1 looked like magic. It isn't — the entire table rests on ONE primitive: *the value at a coordinate is the sum of the facts sitting there.* Right now that primitive is stubbed to return `0`, so every check is red. **Write the one line, and the cells, row totals, column totals and grand total all light up green** — because they are all built on top of it.
You are re-implementing GroupRowsBy / GroupColumnsBy by hand. Once Cell is right, RowTotal, ColTotal and Grand — already written for you — need no further work. That is the whole claim of Lesson 1: one grouping rule generates every view.
The rules
- Everything except the body of
Cellis written for you. Fill in the one line — replace the0. - The eight checks are fixed truths about the cube. Do not change them; make them pass.
Cell(position, year)must return the sum of theAmountof every fact whosePositionandYearboth match. Run until all eight say ✓.
If you are tempted to hard-code the totals, don't — that is exactly the double-entry the cube exists to abolish.
Your workbench
Notice what you did not have to write: no separate formula for row totals, column totals, or the grand total. One primitive, folded two ways, produced the entire table. That is the cube.
Stuck or done? Reveal the solution — the one line filled in, with every check green.