Problem 43131. Which coins to give
I was in shop today. I admired, how shop assistant had to think, which coins to give me. The task is we have a vector v=[0.5 0.2 0.1 0.05 0.02 0.01] and we have a number in range x=0.01-1
return as output a vector of coins which can be given to get summary the "x" amount, also it should be the lowest amount of coins.
Example
x=0.63
v=[0.5 0.2 0.1 0.05 0.02 0.01]
y=[ 1 0 1 0 1 1 ]
Solution Stats
Problem Comments
-
1 Comment
Rafael S.T. Vieira
on 15 Sep 2020
This problem is hard due the precision error that floating-point numbers have. The number 0.1 may not be equal to 0.1, be careful.
Solution Comments
Show commentsProblem Recent Solvers97
Suggested Problems
-
Remove all the words that end with "ain"
2275 Solvers
-
292 Solvers
-
Permute diagonal and antidiagonal
439 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1052 Solvers
-
308 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!