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.

  1. Write an outer loop that cycles from 1 to size.
  2. Inside that cycle, write an inner loop that also cycles from 1 to size.
  3. At the center of these cycles, print the coordinate in this format: (row, col).
  4. 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

Inputsize = 3
Output(1, 1) (1, 2) (1, 3) --- ...

Explanation: Creates a 3x3 coordinate map.

02EXAMPLE 2

Inputsize = 2
Output(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
JavaScript
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