D'Hondt Method of Proportional-Representation - MATLAB Cody - MATLAB Central

Problem 44899. D'Hondt Method of Proportional-Representation

The D'Hondt method is a proportional representational method for allocating seats to parties in an election.

https://en.wikipedia.org/wiki/D%27Hondt_method

Take a vector of votes cast for a number of parties and the total number of seats to be won. Return a vector of the same size showing the allocation of the seats won.

The process is:

  1. Allocate 1 seat to the party with the most votes
  2. Divide that party's original number of votes by the number of seats allocated to it + 1.
  3. Repeat until all seats have been allocated

Note: the total number of seats to be won will always be a positive integer and no ties will need to be resolved to allocate the seats.

Solution Stats

45.0% Correct | 55.0% Incorrect
Last Solution submitted on Aug 01, 2024

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8

Problem Recent Solvers8

Suggested Problems

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!