Cody

# Problem 42316. Fraction of a fraction of a ...

Solution 671104

Submitted on 18 May 2015 by Binbin Qi
• Size: 18
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% frac_str = 'two-sevenths of five-ninths of three-eighths of 168'; assert(isequal(round(fraction_of_a(frac_str)),10))

2   Pass
%% frac_str = 'one-fifth of four-halfs of three-fourths of 100'; assert(isequal(round(fraction_of_a(frac_str)),30))

3   Pass
%% frac_str = 'two-thirds of three-fourths of one-fifth of 150'; assert(isequal(round(fraction_of_a(frac_str)),15))

4   Pass
%% frac_str = 'five-sevenths of four-fifths of three-halfs of two-sixths of one-fourth of 210'; assert(isequal(round(fraction_of_a(frac_str)),15))

5   Pass
%% frac_str = 'one-seventh of two-ninths of 630'; assert(isequal(round(fraction_of_a(frac_str)),20))

6   Pass
%% frac_str = 'one-half of three-fifths of two-thirds of three-fourths of 1000'; assert(isequal(round(fraction_of_a(frac_str)),150))

7   Pass
%% frac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288'; assert(isequal(round(fraction_of_a(frac_str)),4032))

8   Pass
%% frac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288'; assert(isequal(round(fraction_of_a(frac_str)),4032))

9   Pass
%% ind = randi(4); switch ind case 1 frac_str = 'two-sevenths of five-ninths of three-eighths of 168'; assert(isequal(round(fraction_of_a(frac_str)),10)) case 2 frac_str = 'one-fifth of four-halfs of three-fourths of 100'; assert(isequal(round(fraction_of_a(frac_str)),30)) case 3 frac_str = 'two-thirds of three-fourths of one-fifth of 150'; assert(isequal(round(fraction_of_a(frac_str)),15)) case 4 frac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288'; assert(isequal(round(fraction_of_a(frac_str)),4032)) end

10   Pass
%% ind = randi(4); switch ind case 1 frac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288'; assert(isequal(round(fraction_of_a(frac_str)),4032)) case 2 frac_str = 'one-fifth of four-halfs of three-fourths of 100'; assert(isequal(round(fraction_of_a(frac_str)),30)) case 3 frac_str = 'one-seventh of two-ninths of 630'; assert(isequal(round(fraction_of_a(frac_str)),20)) case 4 frac_str = 'two-thirds of three-fourths of one-fifth of 150'; assert(isequal(round(fraction_of_a(frac_str)),15)) end

11   Pass
%% ind = randi(4); switch ind case 1 frac_str = 'one-fifth of four-halfs of three-fourths of 100'; assert(isequal(round(fraction_of_a(frac_str)),30)) case 2 frac_str = 'two-sevenths of five-ninths of three-eighths of 168'; assert(isequal(round(fraction_of_a(frac_str)),10)) case 3 frac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288'; assert(isequal(round(fraction_of_a(frac_str)),4032)) case 4 frac_str = 'one-seventh of two-ninths of 630'; assert(isequal(round(fraction_of_a(frac_str)),20)) end

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!