This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Hi everyone
I could use a bit of help on this solution, as i am just a freshman. By reading it now line 4 mind sound strange, but without it, it didn't work. I always had one penny less than expected. I thought, that this could be a numerical problem using mod() and fix() in the way, that the mod function decreases the value a litte bit and than fix doesn't work right. I am not quiet sure and could need some help by an experienced matlab user. Thanks in advance and a nice day :)
Lukas
In test case 2, 135.01 is represented internally as 135.009999999999991, so the fractional part is slightly less than 0.01, which leads to the problem. You could try rounding the input (and the change vector) to an integer number of pennies so all the calculations would use integers.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!