an implementation of vending machine problem