The patch is right
Why it matters After a few bugs that lie, every small patch starts to look suspicious. Some bugs are exactly what they look like. Rewriting a helper to feel safe costs review time and brings new bugs of its own.
A job sends records to an API in batches. The night shift noticed the last records never arrive:
chunks([1, 2, 3, 4, 5, 6, 7], 3)
# expected [[1, 2, 3], [4, 5, 6], [7]]
# got [[1, 2, 3], [4, 5, 6]]Ask the three questions from the first lesson. What is the true sentence? Which other inputs share the cause? Then decide how big the fix needs to be.
Fix chunks(items, size): return the items split into batches of size, in order, the last batch holding whatever is left (an empty list gives no batches). The hidden tests try every length from 0 to 39 with batch sizes 1 to 8. Rule: the team keeps helpers small: your whole code may have at most 80 syntax nodes (code_size).
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.