iconEuler Examples

D'Hondt and Hare-Niemeyer

D'Hondt and Hare-Niemeyer algorithm.

Needs to be loaded with "load hondt".

function hondt (v,n)

  Distributions of seats with d'Hondt
 
  Compute the distribution of seats s[1],...s[k], which corresonds
  to v[1],...,v[k], such that sum s[i] = n, using d'Hondt.
 
  See: hnbest
function hnbest (v,n)

  Best distribution of seats with Hare-Niemeyer
 
  Compute the distribution of seats s[1],...s[k], which corresonds
  to v[1],...,v[k], such that sum s[i] = n, using closest fit.
  The method minimizes the sum of absolute errors and is
  often called Hare-Niemeyer method.
 
  See: hondt

Examples