The Grid Architect
EasyAcc. 94.2%
+20 XP 8
Dimensions of Logic
Iteration doesn't have to be linear. In this mission, you will build a coordinate system by placing one loop inside another. This allows you to visit every point in a grid.
The Assignment
Your function receives a parameter named size.
- Write an outer loop that cycles from 1 to
size. - Inside that cycle, write an inner loop that also cycles from 1 to
size. - At the center of these cycles, print the coordinate in this format: (row, col).
- After each complete cycle of the inner loop (but still within the outer loop), print a separator: "---" (three dashes).
The Result
The machine will output every coordinate for each row, separating them with dashes.
01EXAMPLE 1
Input
size = 3Output
(1, 1)
(1, 2)
(1, 3)
---
...Explanation: Creates a 3x3 coordinate map.
02EXAMPLE 2
Input
size = 2Output
(1, 1)
(1, 2)
---
(2, 1)
(2, 2)
---Explanation: Creates a 2x2 coordinate map.
Constraints
- Use nested for loops.
- Separator must contain exactly three dashes.
LoopsNested LoopsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
size3
Expected Output
(1, 1) (1, 2) (1, 3) --- (2, 1) (2, 2) (2, 3) --- (3, 1) (3, 2) (3, 3) ---
Click RUN to test your solution