Reserve and settle a shared budget
Simulate a sequential ledger with integer credits. Reserve atomically in this simulation if available capacity is sufficient; otherwise append False to decisions. An identical active reservation appends True without double reserving. Settlement charges at most the reservation and releases its remainder. Identical settlement is idempotent; conflicting reuse fails. Cancel only represents confirmed **pre-dispatch** cancellation and releases capacity; repeated cancel is harmless. Closed IDs cannot be reserved again. Unknown operations, negative values, and overruns raise ValueError. Production concurrency and uncertain provider usage are outside this simulator.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Inputlimit 10; reserve a=7; reserve b=4
Outputdecisions [True,False], available 3
Inputreserve a=7; settle a=5; reserve b=4
Outputspent 5, reserved 4, available 1
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor