Beta

Seat Allocation Double Dutch

1 of 19FrankK

Description:

It is election time in The Netherlands! After the votes are counted it is always a hassle to allocate the seats for the Dutch parliament, called the Second Chamber.

Can you help the Dutch and write a program that can allocate the seats?

Task:

Finish method:

    public string[] GetSeatAllocation(string[] votes, string[] combinations)
    public String[] getSeatAllocation(String[] votes, String[] combinations)
    function getSeatAllocation(votes, combinations)
    def get_seat_allocation(votes, combinations)

Input:

  • Votes is a list of key-value pairs. Party (key) and votes (value) are split by a `|`:
    { "VVD|2504948", "CDA|801620", ... }
    { "VVD|2504948", "CDA|801620", ... }
    [ 'VVD|2504948', 'CDA|801620', ... ]
    [ 'VVD|2504948', 'CDA|801620', ... ]
  • Combinations is the list of alliances that parties can form. The parties of an alliance are seperated by a `|`:
    { "PvdA|SP|GroenLinks", "ChristenUnie|SGP", ... }
    { "PvdA|SP|GroenLinks", "ChristenUnie|SGP", ... }
    [ 'PvdA|SP|GroenLinks', 'ChristenUnie|SGP', ... ]
    [ 'PvdA|SP|GroenLinks', 'ChristenUnie|SGP', ... ]

Output:

  • A list of key-value pairs where party is the key and number of seats the value. Only parties that have gained at least 1 seat are included. The order is the number of seats descending, then number of votes descending:
    { "VVD|41", "CDA|13", ... }
    { "VVD|41", "CDA|13", ... }
    [ 'VVD|41', 'CDA|13', ... ]
    [ 'VVD|41', 'CDA|13', ... ]

Rules:

  • There are exactly 150 seats to be assigned.
  • For each seat a party will need at least 1/150 of the total number of votes (quota).
  • Combinations of parties are treated as 1 party.
  • Parties without enough votes for at least 1 seat are excluded from remainder seats.
  • Parties without enough votes for at least 1 seat on their own are also excluded from the combinations they subscribed to and their votes are also not counted for those combinations .
  • The residual seats are assigned to the parties with the highest average of votes per seat.
The allocation of the residual seats is in favor of the bigger parties. Forming an alliance with other parties is a possibility for smaller parties to mitigate their size disadvantage in the assignment of residual seats.

Rules within combinations:

  • A combination is treated as 1 party but after the standard allocation the seats gathered by the combination need to be allocated again to its individual members.
  • The votes needed for a seat (quota) is the total votes of the combination divided by the seats assigned to the combination.
  • Residual seats are assigned to the parties of a combination based on the largest remainder of votes per seat.

The option to form an alliance was removed in 2017 by the Dutch government because of the fragmentation of the political landscape.

Dutch general elections of 2012:

  • Total votes: 9,424,235
  • Seats: 150
  • Election quota: 62,829
  • Combinations:
    • PvdA - SP - GroenLinks
    • ChristenUnie - SGP

Party Votes Votes / quota Seats Res. seats Total seats
  VVD   2,504,948   39.87   39   +2   41
  PvdA   2,340,750   37.22   37   +1   38
  PVV   950,263   15.12   15      15
  SP   909,853   14.48   14   +1   15
  CDA   801,620   12.76   12   +1   13
  D66   757,091   12.05   12      12
  ChristenUnie   294,586   4.69   4   +1   5
  GroenLinks   219,896   3.50   3   +1   4
  SGP   196,780   3.13   3      3
  PvdD   182,162   2.90   2      2
  50Plus   177,631   2.83   2      2
  Piratenpartij   30,600   0.49   0      0
  MenS   18,310   0.29   0      0
  SOPN   12,982   0.21   0      0
  PvdT   8,194   0.13   0      0
  DPK   7,363   0.11   0      0
  LP   4,163   0.07   0      0
  Nederland Lokaal   2,842   0.05   0      0
  LibDem   2,126   0.03   0      0
  Anti Europa Partij   2,013   0.03   0      0
  NXD   62   0.00   0      0
Mathematics
Algorithms

Stats:

CreatedJan 13, 2017
PublishedJan 13, 2017
Warriors Trained814
Total Skips403
Total Code Submissions217
Total Times Completed19
C# Completions1
Java Completions3
JavaScript Completions4
Python Completions15
Total Stars24
% of votes with a positive feedback rating96% of 12
Total "Very Satisfied" Votes11
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments11
Average Assessed Rank
4 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • FrankK Avatar
  • hobovsky Avatar
Ad