Ad
  • Custom User Avatar

    You are absolutely right. I have realized that my solution was wrong. Now I have refactored it and I have added some more test:

    vm = new VendingMachine({1:0, 3:2, 5:1, 8:0});
    Test.assertSimilar(vm.vending(9, {8:2}), {3:2});
    Test.assertSimilar(vm.coins, {1:0, 3:0, 5:1, 8:2});
    
    vm = new VendingMachine({20:0, 9:2, 5:2})
    Test.assertSimilar(vm.vending(1, {20:1}), {5:2,9:1});
    Test.assertSimilar(vm.coins, {5:0,9:1,20:1});
    

    Thanks a lot!