Cody

# Problem 44763. Pumpkin Pie!

Solution 1731558

Submitted on 20 Feb 2019
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
already_cut_fractions = [1/4 1/4 1/4]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.704)<1e-2)

2   Fail

Assertion failed.

3   Pass
already_cut_fractions = [1/4 1/4 1/4 1/4 1/4 1/4 1/4 1/4]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(strcmpi(slice_fraction,'pass'))

4   Pass
already_cut_fractions = [1/8 1/8 1/8 1/8]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.787)<1e-2)

5   Pass
already_cut_fractions = [1/16 1/32]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.862)<1e-2)

6   Pass
already_cut_fractions = [1/7 1/5 1/6 1/4 1/8 1/10 1/9]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.583)<1e-2)

7   Pass

8   Fail

Assertion failed.

9   Pass
already_cut_fractions = [1/3 1/5 1/7 1/11 1/13 1/17 1/19 1/23 1/29 1/31]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.591)<1e-2)

10   Pass
already_cut_fractions = [1/3 1/4 1/2 1/3 1/6]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(ischar(slice_fraction)) str_parts = cellfun(@str2num,regexp(slice_fraction,'/','split')); assert(numel(str_parts)==2) slice_dec = str_parts(1) / str_parts(2); assert(abs(slice_dec - 0.1)<1e-2)

### Community Treasure Hunt

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

Start Hunting!