RAG and Vector Search · Exercise 1 of 5Next
Beginner
Children to parents
Hits are (child_id, score) pairs, best first, and a child id looks like D50.2 (the parent id is the part before the dot).
Write parents_for(hits, min_score): ignore hits whose score is below min_score, map each remaining hit to its parent id, remove repeats and keep the order of first appearance. Return the list of parent ids.
What Check tests
- Children map to their parents
- Repeats are removed
- Order of first appearance is kept
- Weak hits are ignored
- No hits gives an empty list
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.