Cody

Problem 577. Repopulate the City

Solution 1693398

Submitted on 16 Dec 2018 by Augusto Mazzei
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

ahah = 4 v = 0 0 0 0 0 0 0 4 ahah = 0 v = 0 0 0 0 0 0 0 4 ahah = 2 v = 0 0 0 0 0 2 0 4 ahah = 1 v = 0 0 0 0 1 2 0 4 ahah = 2 v = 0 0 0 2 1 2 0 4 ahah = 0 v = 0 0 0 2 1 2 0 4 ahah = 0 v = 0 0 0 2 1 2 0 4 ahah = 1 v = 1 0 0 2 1 2 0 4 p = [] p = 23 p = 23 22 22 p = 23 22 22 28 p = 23 22 22 28 20 20 p = 23 22 22 28 20 20 24 24 24 24 p = 23 22 22 28 20 20 24 24 24 24

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

ahah = 1 v = 0 0 0 0 0 0 0 0 0 0 0 1 ahah = 11 v = 0 0 0 0 0 0 0 0 0 0 11 1 ahah = 2 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 2 11 1 ahah = 4 v = 0 0 4 0 0 0 0 0 0 2 11 1 ahah = 4 v = 0 4 4 0 0 0 0 0 0 2 11 1 ahah = 18 v = 18 4 4 0 0 0 0 0 0 2 11 1 p = [] p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 7 7 7 7 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 7 7 7 7 21 21 p = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 7 7 7 7 21 21 15 15 Columns 31 through 39 15 15 15 15 15 15 15 15 15 p = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 7 7 7 7 21 21 15 15 Columns 31 through 40 15 15 15 15 15 15 15 15 15 45

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

ahah = 1 v = 0 0 0 0 0 0 0 0 0 1 ahah = 0 v = 0 0 0 0 0 0 0 0 0 1 ahah = 1 v = 0 0 0 0 0 0 0 1 0 1 ahah = 0 v = 0 0 0 0 0 0 0 1 0 1 ahah = 0 v = 0 0 0 0 0 0 0 1 0 1 ahah = 0 v = 0 0 0 0 0 0 0 1 0 1 ahah = 0 v = 0 0 0 0 0 0 0 1 0 1 ahah = 0 v = 0 0 0 0 0 0 0 1 0 1 ahah = 1 v = 0 1 0 0 0 0 0 1 0 1 ahah = 17 v = 17 1 0 0 0 0 0 1 0 1 p = [] p = 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 p = 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 110 p = 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 110 176 p = 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 110 176 144

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

ahah = 1 v = 0 0 0 0 0 0 1 ahah = 6 v = 0 0 0 0 0 6 1 ahah = 0 v = 0 0 0 0 0 6 1 ahah = 5 v = 0 0 0 5 0 6 1 ahah = 8 v = 0 0 8 5 0 6 1 ahah = 0 v = 0 0 8 5 0 6 1 ahah = 40 v = 40 0 8 5 0 6 1 p = [] 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 40 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 48 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 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 53 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 33 33 33 33 33 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 59 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 33 33 33 33 33 30 30 30 30 30 30 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 5 5 5 5 5 6 6 6 6 6 6 6 6 33 33 33 33 33 30 30 30 30 30 30 20