Intermediate
Merge results from shards
Write scatter_gather(shards, score, k). shards is a list of lists of document ids, and score(doc_id) returns a number. From each shard take its best k documents, then merge them and return the best k document ids overall.
Order by score from highest to lowest, with ties broken by document id (ascending).
What Check tests
- Returns the global best three
- Fewer documents than k
- Ties are broken by id
- Takes k from every shard
- Empty shards are fine
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.