Cody

# Problem 577. Repopulate the City

Solution 1733620

Submitted on 22 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   Fail
pmin = 20; pmax = 30; d = [1 2 3 4 5]; n = [10 9 4 7 2]; p = fit_distribution(d,n,pmin,pmax) assert(~any(p<pmin) && ~any(p>pmax)) for i = 1:length(d) assert(isequal(n(i), sum(rem(p,d(i))==0))) end

a = 10×1 cell array {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double} {1×11 double}

Index exceeds array bounds. Error in fit_distribution (line 6) tmp(j)=any(rem(a{j},d(i))==0); Error in Test1 (line 6) p = fit_distribution(d,n,pmin,pmax)

2   Fail
pmin = 1; pmax = 50; d = [1 3 5 7 8 9]; n = [40 14 12 6 4 1]; p = fit_distribution(d,n,pmin,pmax); assert(~any(p<pmin) && ~any(p>pmax)) for i = 1:length(d) assert(isequal(n(i), sum(rem(p,d(i))==0))) end

a = 40×1 cell array {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double} {1×50 double}

Index exceeds array bounds. Error in fit_distribution (line 6) tmp(j)=any(rem(a{j},d(i))==0); Error in Test2 (line 6) p = fit_distribution(d,n,pmin,pmax);

3   Fail
pmin = 100; pmax = 200; d = [1 8 9 15 22]; n = [20 2 1 0 2]; p = fit_distribution(d,n,pmin,pmax); assert(~any(p<pmin) && ~any(p>pmax)) for i = 1:length(d) assert(isequal(n(i), sum(rem(p,d(i))==0))) end

a = 20×1 cell array {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double} {1×101 double}

Index exceeds array bounds. Error in fit_distribution (line 6) tmp(j)=any(rem(a{j},d(i))==0); Error in Test3 (line 6) p = fit_distribution(d,n,pmin,pmax);

4   Pass
pmin = 5; pmax = 37; d = [1 10 20 3 11]; n = [60 7 1 19 5]; p = fit_distribution(d,n,pmin,pmax); assert(~any(p<pmin) && ~any(p>pmax)) for i = 1:length(d) assert(isequal(n(i), sum(rem(p,d(i))==0))) end

a = 60×1 cell array {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} {1×33 double} c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 c = 10 20 30 c = 10 20 30 c = 10 20 30 c = 10 20 30 c = 10 20 30 c = 10 20 30 c = 10 20 30 c = 10 30 c = 10 30 c = 10 30 c = 10 30 c = 10 30 c = 10 30 c = 20 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 11 13 14 16 17 19 22 23 25 26 28 29 31 32 34 35 37 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 6 9 12 15 18 21 24 27 33 36 c = 30 c = 30 c = 30 c = 30 c = 30 c = 30 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 7 8 13 14 16 17 19 23 25 26 28 29 31 32 34 35 37 c = 5 ...