Cody

Solution 2002828

Submitted on 5 Nov 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   Pass
votes = [100]; seats = 1; v_c = 1; assert(isequal(dHondt(votes,seats),v_c))

2   Pass
votes = [30,40,60,50]; seats = 1; v_c = [0,0,1,0]; assert(isequal(dHondt(votes,seats),v_c))

3   Fail
votes = [428010,363033,330470,75648,71464]; seats = 7; v_c = [3,2,2,0,0]; assert(isequal(dHondt(votes,seats),v_c))

Matrix dimensions must agree. Error in dHondt (line 3) X = votes * 1./(1:seats); Error in Test3 (line 4) assert(isequal(dHondt(votes,seats),v_c))

4   Fail
votes = [80000,30000,100000,20000]; seats = 8; v_c = [3,1,4,0]; assert(isequal(dHondt(votes,seats),v_c))

Matrix dimensions must agree. Error in dHondt (line 3) X = votes * 1./(1:seats); Error in Test4 (line 4) assert(isequal(dHondt(votes,seats),v_c))

5   Fail
votes = [100,800,1000,800,600,100]; seats = 9; v_c = [0,2,3,2,2,0]; assert(isequal(dHondt(votes,seats),v_c))

Matrix dimensions must agree. Error in dHondt (line 3) X = votes * 1./(1:seats); Error in Test5 (line 4) assert(isequal(dHondt(votes,seats),v_c))