bugger.
All challenges/Pythonmediumcuda-exclusive-scan-v1
THE INVESTIGATION

Scan within blocks

Compute an exclusive prefix sum independently for each block.

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 integer values and a positive block_size, return {"scan": [...], "block_sums": [...]}. For each consecutive block_size chunk, scan contains the sum of earlier values in the same chunk, excluding the current value. block_sums contains each entire chunk sum, including a partial final chunk. Empty input produces two empty lists.

Expected behavior

Compute an exclusive prefix sum independently for each block.

Reproduction

01 Case 1
{"values": [1, 2, 3, 4, 5], "block_size": 2}
{"scan": [0, 1, 0, 3, 0], "block_sums": [3, 7, 5]}
02 Case 2
{"values": [2, 3, 4], "block_size": 4}
{"scan": [0, 2, 5], "block_sums": [9]}
03 Case 3
{"values": [], "block_size": 3}
{"scan": [], "block_sums": []}

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.