Cody

Problem 2126. Split bread like the Pharaohs - Egyptian fractions and greedy algorithm

Solution 1905247

Submitted on 19 Aug 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   Fail
% Updated test suite to remove trivial solutions; % Small Vmin = 10; Vmax = 55; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

Undefined function 'problem2126' for input arguments of type 'double'. Error in egyptian_fraction (line 14) denoms = [ceil(q/p) problem2126(prod(a), prod(b))]; Error in Test1 (line 5) denom = floor(unique(egyptian_fraction(Vmin,Vmax)));

2   Fail
% Pie Vmin = 113; Vmax = 355; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

Undefined function 'problem2126' for input arguments of type 'double'. Error in egyptian_fraction (line 14) denoms = [ceil(q/p) problem2126(prod(a), prod(b))]; Error in Test2 (line 3) denom = floor(unique(egyptian_fraction(Vmin,Vmax)));

3   Fail
% Ramanujan Vmin = 1023; Vmax = 1729; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

Undefined function 'problem2126' for input arguments of type 'double'. Error in egyptian_fraction (line 14) denoms = [ceil(q/p) problem2126(prod(a), prod(b))]; Error in Test3 (line 3) denom = floor(unique(egyptian_fraction(Vmin,Vmax)));

4   Fail
% E Vmin = 27; Vmax = 183; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

Undefined function 'problem2126' for input arguments of type 'double'. Error in egyptian_fraction (line 14) denoms = [ceil(q/p) problem2126(prod(a), prod(b))]; Error in Test4 (line 3) denom = floor(unique(egyptian_fraction(Vmin,Vmax)));