Problem statement
Two questions over one grid. Either read every cell in spiral order, or rotate the grid 90 degrees clockwise in place.
Both are decided by four boundary numbers: the top row, the bottom row, the left column and the right column.
Examples
Inputm = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Output[1, 2, 3, 6, 9, 8, 7, 4, 5]
The ring is read clockwise and then the centre cell forms the next ring.
Inputm = [[1, 2, 3, 4]]
Output[1, 2, 3, 4]
A single row is read by the top pass, and the bottom pass must be skipped or the row repeats.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing