THE INVESTIGATION
Partition a global batch
Partition ordered example IDs into contiguous, balanced worker shards without loss or duplication.
LLM ArchitectureML systems
What’s going wrong
Original LLM Architecture lab. Implement solve(data) using the Python standard library.
Given data["examples"] and a positive integer data["workers"], return a list of contiguous lists. Divide examples as evenly as possible; earlier workers receive one extra example when needed. Empty workers receive an empty list.
Expected behavior
Partition ordered example IDs into contiguous, balanced worker shards without loss or duplication.
Reproduction
01 Case 1
{"examples": [0, 1, 2, 3, 4], "workers": 2}[[0, 1, 2], [3, 4]]
02 Case 2
{"examples": [1, 2], "workers": 4}[[1], [2], [], []]
03 Case 3
{"examples": [], "workers": 2}[[], []]
Before you begin
- Python lists and dictionaries
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.
Ready when you are
Every fix starts with a failing test.
Read the report, then sign in to start your investigation.