bugger.
All challenges/Pythonmediumcuda-matrix-index-v1
THE INVESTIGATION

Map a two-dimensional launch

Map a two-dimensional grid of threads onto matrix coordinates.

LLM ArchitectureML systems

What’s going wrong

Original LLM Architecture lab. This CUDA fundamentals exercise is a deterministic Python simulation, not CUDA code or GPU execution. Implement solve(data) using the Python standard library.

Given nonnegative rows and cols, grid_x and grid_y, and positive block_x and block_y, return {"threads": [[row, col, active], ...]} in block-y, block-x, thread-y, thread-x order. row = block_y_id * block_y + thread_y; col = block_x_id * block_x + thread_x. active is true only within the matrix.

Expected behavior

Map a two-dimensional grid of threads onto matrix coordinates.

Reproduction

01 Case 1
{"rows": 2, "cols": 3, "grid_x": 2, "grid_y": 1, "block_x": 2, "block_y": 2}
{"threads": [[0, 0, true], [0, 1, true], [1, 0, true], [1, 1, true], [0, 2, true], [0, 3, false], [1, 2, true], [1, 3, false]]}
02 Case 2
{"rows": 2, "cols": 2, "grid_x": 1, "grid_y": 1, "block_x": 2, "block_y": 2}
{"threads": [[0, 0, true], [0, 1, true], [1, 0, true], [1, 1, true]]}
03 Case 3
{"rows": 0, "cols": 3, "grid_x": 1, "grid_y": 1, "block_x": 2, "block_y": 1}
{"threads": [[0, 0, false], [0, 1, false]]}

Before you begin

  • Python lists and loops

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.