Medium
A Pool of Resources
A
Pool has k free slots. pool.slot() is a context manager that takes a slot on entry (printing take, free=N) and gives it back on exit (printing give, free=N). Read k and a nesting depth d, open d nested with pool.slot(): blocks (recursively), and print full at the innermost level if no slots are free, else ok.Input
Two integers on one line (d ≤ k).
Output
Lines.
Sample 1
Input
2 2
Output
take, free=1 take, free=0 full give, free=1 give, free=2
Sample 2
Input
3 1
Output
take, free=2 ok give, free=3
Output appears here