Cody

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

Solution 719740

Submitted on 22 Aug 2015 by Jean-Marie Sainthillier
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))

ans = 10

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

ans = 30.0000

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

ans = 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))

ans = 15

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

ans = 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))

ans = 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))

ans = 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))

ans = 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

ans = 4032

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

ans = 15

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

ans = 20

### Community Treasure Hunt

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

Start Hunting!