Intermediate
Submit jobs once per idempotency key
Write a class Jobs with submit(key, payload) that returns (job_id, created). The first time a key is seen it creates a job with the id "job-1", "job-2", ... and returns created = True. The same key again returns the same job id and created = False, and creates nothing.
Also add count() that returns how many jobs exist.
What Check tests
- New keys create numbered jobs
- The same key returns the first job and creates nothing
- A repeated key does not use up a job number
count()counts jobs
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.