Cody

Solution 1663202

Submitted on 31 Oct 2018 by goc3
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   Pass
already_cut_fractions = [1/2 1/2 1/2]; slice_fraction = pumpkin_pie(already_cut_fractions); assert(strcmpi(slice_fraction,'pass'))

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
already_cut_fractions = 1/16 * ones(1,33); slice_fraction = pumpkin_pie(already_cut_fractions); assert(strcmpi(slice_fraction,'pass'))

8   Pass
already_cut_fractions = 7/8; slice_fraction = pumpkin_pie(already_cut_fractions); assert(strcmpi(slice_fraction,'pass'))

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)