Problem 42316. Fraction of a fraction of a ...
One sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,
- What is one-seventh of two-ninths of 630?
You will be supplied with various strings of this format (minus the "What is" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while "of" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:
- 1/7 * 2/9 * 630
which, when evaluated, will yield 20. See the test suite for more examples.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
331 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
365 Solvers
-
Calculate distance travelled when given radius and rotations
222 Solvers
-
Diagonal & Anti-Diagonal Matrix: Easy
93 Solvers
-
07 - Common functions and indexing 1
431 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!