Intermediate
Plan a sync and prove it is idempotent
stored and wanted are dictionaries from chunk id to section name. Write plan_sync(stored, wanted) returning a dictionary with three sorted lists: add (ids only in wanted), update (ids in both whose section differs) and delete (ids only in stored).
Write apply_plan(stored, wanted, plan) that returns the new stored dictionary after the plan is applied. Applying a plan and then planning again must give three empty lists.
What Check tests
- New ids are added
- Missing ids are deleted
- A changed section is an update, not an add
- Equal dictionaries need no work
- Applying the plan makes the store equal to wanted
- Planning again after applying gives an empty plan
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.