Practice · 5 of 5
Spiral fill
CHALLENGE
Difficulty: advanced+25 XP
Fill a rows x cols grid counting from 1 in **spiral order**: top row left→right, right column top→bottom, bottom row right→left, left column bottom→top, then shrink inward. Implement fill(int rows, int cols) returning the grid.
Example: 3×4 → {{1,2,3,4},{10,11,12,5},{9,8,7,6}}.
Press Submit to check your solution.
Back to lesson: Practice: Grid lab: axes, neighborhoods, walls