Command Palette

Search for a command to run...

Hectal
Phase 7: Query Understanding
RAG and Vector Search · Exercise 2 of 6 PreviousNext
Intermediate

Fuse ranked lists with RRF

Write fuse(rankings), where rankings is a list of lists of passage ids (best first). Give each id 1 / (60 + rank) for every list it is in (rank starts at 1), add the scores, and return the ids as a list, best first.

Ids with equal scores keep the order in which they were first seen.

What Check tests

  1. An id in two lists rises
  2. One list stays in order
  3. No lists gives an empty list
  4. Ties keep first-seen order
  5. A top rank beats a lower rank

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.