Problem 42386. Faint Receipt
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
Show
6 older comments
goc3
on 17 Jun 2015
That link doesn't work as written (at least, it didn't for me). It does function, though, if you truncate the url at #.
Christian Schröder
on 20 Nov 2022
Could I convince you to not use isequal() when comparing floating point numbers in the test suite?
goc3
on 12 Apr 2023
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.
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
-
1357 Solvers
-
given 3 sides, find area of this triangle
807 Solvers
-
Flip the main diagonal of a matrix
838 Solvers
-
Back to basics - mean of corner elements of a matrix
428 Solvers
-
182 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!