156. Product domains walk row-major; P.nth(k) decodes a flat cell number (2026-11-21)
- Decision. A product domain
P = (A, B)is ordered row-major (the last factor fastest), soP.nth(k)turns a flat 0-based cell number into a position andP.itemspairs each cell with its flat number. - Why. NOI 2014 numbers grid cells 1..=n·m. The port divided by
mby hand (Row((at[v] - 1) / m + 1)), the C++ habit domains exist to remove. The blind dream wroteCell.nth(i). - Reverse. Drop the
P.nthrow fromspec/core/04-indices.md.