Answer to exercise 6.11, Candy Dispenser.