{"id":4971,"date":"2023-09-04T15:00:14","date_gmt":"2023-09-04T08:00:14","guid":{"rendered":"https:\/\/kamnotra.io\/en\/?page_id=4971"},"modified":"2023-09-04T15:00:15","modified_gmt":"2023-09-04T08:00:15","slug":"seat-calculator","status":"publish","type":"page","link":"https:\/\/kamnotra.io\/en\/succession\/cambodia-election-2023\/seat-calculator\/","title":{"rendered":"Seat Calculator"},"content":{"rendered":"\n<p>See Also: <a href=\"https:\/\/kamnotra.io\/en\/succession\/cambodia-election-2023\/\">Results<\/a>, <a href=\"https:\/\/kamnotra.io\/en\/succession\/cambodia-election-2023\/statements-reactions\/\">Statements, Reactions<\/a>, <a href=\"https:\/\/kamnotra.io\/en\/succession\/cambodia-election-2023\/parties-candidates\/\">Parties, Candidates<\/a>, <a href=\"https:\/\/kamnotra.io\/en\/succession\/cambodia-election-2023\/past-elections\/\">Past Elections<\/a><\/p>\n\n\n\n<p>Seats are calculated by first dividing a province\u2019s valid votes by the number of seats on offer. For example, 12,000 votes for Phnom Penh\u2019s 12 seats gives a \u201cquotient\u201d of 1,000.<\/p>\n\n\n\n<p>In the first round of calculations, parties receive one seat for every \u201cquotient,\u201d e.g. 5,500 votes would give five seats for the previous example.<\/p>\n\n\n\n<p>The remaining seats are then allocated one by one to the party with the most votes after dividing their vote counts by the number of seats they\u2019ve so far been allocated plus one. For example, the party of the previous example would have a score of 5,500 \u00f7 6 for round two.<\/p>\n\n\n\n<div id=\"elec-calc\">\n\t<div id=\"elec-calc-totals\">\n\t\t<label>Total valid votes in province:<\/label>\n\t\t<input id=\"elec-calc-votes\" \/>\n\n\t\t<label>Total seats in province:<\/label>\n\t\t<select onchange=\"document.getElementById('elec-calc-seats').value=this.value;Recalc()\">\n\t\t\t<option value=6>Banteay Meanchey<\/option>\n\t\t\t<option value=8>Battambang<\/option>\n\t\t\t<option value=10>Kampong Cham<\/option>\n\t\t\t<option value=4>Kampong Chhnang<\/option>\n\t\t\t<option value=6>Kampong Speu<\/option>\n\t\t\t<option value=6>Kampong Thom<\/option>\n\t\t\t<option value=6>Kampot<\/option>\n\t\t\t<option value=11>Kandal<\/option>\n\t\t\t<option value=1>Kep<\/option>\n\t\t\t<option value=1>Koh Kong<\/option>\n\t\t\t<option value=3>Kratie<\/option>\n\t\t\t<option value=1>Mondulkiri<\/option>\n\t\t\t<option value=1>Oddar Meanchey<\/option>\n\t\t\t<option value=1>Pailin<\/option>\n\t\t\t<option value=12>Phnom Penh<\/option>\n\t\t\t<option value=3>Preah Sihanouk<\/option>\n\t\t\t<option value=1>Preah Vihear<\/option>\n\t\t\t<option value=11>Prey Veng<\/option>\n\t\t\t<option value=4>Pursat<\/option>\n\t\t\t<option value=1>Ratanakiri<\/option>\n\t\t\t<option value=6>Siem Reap<\/option>\n\t\t\t<option value=1>Stung Treng<\/option>\n\t\t\t<option value=5>Svay Rieng<\/option>\n\t\t\t<option value=8>Takeo<\/option>\n\t\t\t<option value=8>Tbong Khmum<\/option>\n\t\t<\/select>\n\t\t<input id=\"elec-calc-seats\" value=6 \/>\n\n\t\t<label>Quotient:<\/label>\n\t\t<span id=\"elec-calc-threshold\"><\/span>\n\t<\/div>\n\t<div id=\"elec-calc-error\">&nbsp;<\/div>\n\t<table id=\"elec-calc-parties\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>Party<\/th>\n\t\t\t\t<th>Votes<\/th>\n\t\t\t\t<th>Seats<\/th>\n\t\t\t\t<th>Per round<\/th>\n\t\t\t<\/tr>\n\t\t<\/thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>Beehive Social Democratic Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cambodia Indigenous Peoples Democracy Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cambodian Nationality Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cambodian People&rsquo;s Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cambodian Youth Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Democracy Power Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Dharmacracy Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Ekpheap Cheat Khmer Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Farmer&rsquo;s Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Funcinpec<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Grassroots Democratic Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Khmer Anti-Poverty Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Khmer Conservative Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Khmer Economic Development Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Khmer National United Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Khmer United Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>People Purpose Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t\t<tr>\n\t\t\t\t<td>Women for Women Party<\/td>\n\t\t\t\t<td><input class=\"elec-calc-party-votes\" \/><\/td>\n\t\t\t\t<td class=\"elec-calc-party-seats\"><\/td>\n\t\t\t\t<td class=\"elec-calc-party-rounds\"><\/td>\n\t\t\t<\/tr>\n\t\t<\/tbody>\n\t<\/table>\n<\/div>\n\n<style>\n#elec-calc input {\n\twidth: 4rem;\n}\n#elec-calc input, #elec-calc select, #elec-calc table {\n\tfont-family: Roboto, Battambang;\n\tfont-size: 15px;\n}\n#elec-calc th, #elec-calc td {\n\tpadding-right: 1rem;\n}\n#elec-calc-totals input {\n\tmargin-right: 0.5rem;\n}\n#elec-calc-error {\n\tcolor: rgba(0,0,0,0.5);\n\tfont-style: italic;\n}\n.elec-calc-party-rounds {\n\tcolor: rgba(0,0,0,0.5);\n}\n<\/style>\n\n<script>\ndocument.querySelectorAll('#elec-calc input').forEach(input => {\n\tinput.addEventListener('input', Recalc);\n})\nfunction Recalc() {\n\tconst votes = document.getElementById('elec-calc-votes').value || 0;\n\tconst seats = document.getElementById('elec-calc-seats').value || 0;\n\tconst round1 = votes \/ seats;\n\tdocument.getElementById('elec-calc-threshold').innerHTML = Math.floor(round1);\n\tconst rows = document.querySelectorAll('#elec-calc-parties tbody tr');\n\n\t\/\/ Check input\n\tif (Votes() != votes) {\n\t\tdocument.getElementById('elec-calc-error').innerHTML = `Party votes (${Votes()}) don&rsquo;t add up to provincial total (${votes})`;\n\t\trows.forEach(row => {\n\t\t\trow.querySelector('.elec-calc-party-seats').innerHTML = '-';\n\t\t\trow.querySelector('.elec-calc-party-rounds').innerHTML = '-';\n\t\t});\n\t\treturn;\n\t} else {\n\t\tdocument.getElementById('elec-calc-error').innerHTML = '&nbsp;';\n\t}\n\tfunction Votes() {\n\t\tlet total = 0;\n\t\tdocument.querySelectorAll('#elec-calc-parties tbody input').forEach(input => {\n\t\t\ttotal += parseInt(input.value) || 0;\n\t\t});\n\t\treturn total;\n\t}\n\n\t\/\/ Round 1\n\trows.forEach(row => {\n\t\tconst party = row.querySelector('input').value || 0;\n\t\tconst alloc = Math.floor(party \/ round1);\n\t\trow.querySelector('.elec-calc-party-rounds').innerHTML = alloc;\n\t});\n\n\t\/\/ Rounds 2+\n\tlet rounds = 0;\n\twhile (Seats() < seats) {\n\t\tif (rounds >= 100) {\n\t\t\tdocument.getElementById('elec-calc-error').innerHTML = 'Invalid';\n\t\t\tbreak;\n\t\t} else {\n\t\t\tdocument.getElementById('elec-calc-error').innerHTML = '&nbsp;';\n\t\t\trounds += 1;\n\t\t}\n\t\tlet round = [];\n\t\trows.forEach(row => {\n\t\t\tconst party = row.querySelector('input').value || 0;\n\t\t\tconst denominator = eval(row.querySelector('.elec-calc-party-rounds').innerHTML) + 1;\n\t\t\tround.push(party \/ denominator);\n\t\t});\n\t\tconst winner = round.indexOf(Math.max(...round));\n\t\trows.forEach((row, n) => {\n\t\t\tif (n == winner) {\n\t\t\t\trow.querySelector('.elec-calc-party-rounds').innerHTML += ' + 1';\n\t\t\t} else {\n\t\t\t\trow.querySelector('.elec-calc-party-rounds').innerHTML += ' + 0';\n\t\t\t}\n\t\t});\n\t}\n\tfunction Seats() {\n\t\tlet total = 0;\n\t\tdocument.querySelectorAll('#elec-calc-parties tbody .elec-calc-party-rounds').forEach(calc => {\n\t\t\tconst party = eval(calc.innerHTML);\n\t\t\ttotal += party;\n\t\t});\n\t\treturn total;\n\t}\n\n\t\/\/ Final totals\n\trows.forEach(row => {\n\t\tconst total = eval(row.querySelector('.elec-calc-party-rounds').innerHTML);\n\t\trow.querySelector('.elec-calc-party-seats').innerHTML = total;\n\t});\n}\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>See Also: Results, Statements, Reactions, Parties, Candidates, Past Elections Seats are calculated by first dividing a province\u2019s valid votes by the number of seats on offer. For example, 12,000 votes for Phnom Penh\u2019s 12 seats gives a \u201cquotient\u201d of 1,000. In the first round of calculations, parties receive one seat for every \u201cquotient,\u201d e.g. 5,500 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1781,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pgc_sgb_lightbox_settings":"","_FSMCFIC_featured_image_caption":"","_FSMCFIC_featured_image_nocaption":"","_FSMCFIC_featured_image_hide":"","footnotes":""},"class_list":["post-4971","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/pages\/4971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/comments?post=4971"}],"version-history":[{"count":2,"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/pages\/4971\/revisions"}],"predecessor-version":[{"id":4976,"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/pages\/4971\/revisions\/4976"}],"up":[{"embeddable":true,"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/pages\/1781"}],"wp:attachment":[{"href":"https:\/\/kamnotra.io\/en\/wp-json\/wp\/v2\/media?parent=4971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}