Cody

Solution 1666468

Submitted on 5 Nov 2018 by James
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
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

p = 24 27 28 28 28 28 28 28 30 30 p = 24 27 28 28 28 28 28 28 30 30

2   Pass
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

v = Columns 1 through 30 27 40 16 8 8 35 21 14 28 42 14 10 25 5 50 15 25 15 5 15 20 6 12 6 33 12 39 12 6 2 Columns 31 through 40 2 2 2 2 2 2 2 2 2 2 p = Columns 1 through 30 2 2 2 2 2 2 2 2 2 2 2 5 5 6 6 6 8 8 10 12 12 12 14 14 15 15 15 16 20 21 Columns 31 through 40 25 25 27 28 33 35 39 40 42 50

3   Pass
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

v = 189 192 152 154 110 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 p = 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 110 152 154 189 192

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

v = Columns 1 through 30 20 33 22 33 33 22 10 10 30 10 30 30 27 12 24 36 21 12 9 24 36 27 21 21 12 5 5 5 5 5 Columns 31 through 60 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 p = Columns 1 through 30 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Columns 31 through 60 5 5 5 5 5 9 10 10 10 12 12 12 20 21 21 21 22 22 24 24 27 27 30 30 30 33 33 33 36 36