Suppose you have a receipt with some numbers that have been smudged or didn't print. In particular, the total amount is missing the first and last digits. The purchase did not involve tax (or you're looking at the subtotal before tax), only one item was purchased, and the quantity of the item is known. Use this data to determine what the total amount was, assuming that the unit cost does not contain a fraction of a cent. The partially known total will be provided as a string with an X for the unknown first and last digits.
In some cases, there will be multiple possible answers. We're going to assume the best and return the lowest possible total. The second missing digit can range from 0 to 9, though the first missing digit is the leading number, and, therefore, cannot be zero.
Solution Stats
Problem Comments
9 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers19
Suggested Problems
-
1359 Solvers
-
Project Euler: Problem 5, Smallest multiple
1648 Solvers
-
How long do each of the stages of the rocket take to burn?
451 Solvers
-
6088 Solvers
-
Count number of words in string
186 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
there may be a few incorrect tests here (e.g. test 2 with 'X31.6X' and qty=111 should return '531.69' if I am interpreting correctly)
agree with alfonso
I had the same issue with that particular test case.
I've updated the test suite. It should work now. I selected the option to have all previous solutions rescored, but I've never actually seen that option work for other problems I've worked on, so just submit your solutions again. Also, refer to comments on http://www.mathworks.com/matlabcentral/cody/problems/42385-combined-ages-4-non-symmetric-with-multiples-n-3 regarding not being able to use the "Test reference solution" button currently. Is anyone else having that problem?
I believe rescoring doesn't work immediately, but all solutions seem to be rescored now. "Test reference solution" doesn't work for me neither. As far as I remember it's not the first time it doesn't work (on my account), but previous incidents had shorter duration (week or so).
http://www.mathworks.com/matlabcentral/cody/solutions/686845#comment_5568
That link doesn't work as written (at least, it didn't for me). It does function, though, if you truncate the url at #.
Could I convince you to not use isequal() when comparing floating point numbers in the test suite?
Christian, generally, I would change out isequal(). However, in this case, the problem is dealing with currency; therefore, each amount has a fixed precision: two decimal places.