Beta
Seat Allocation Double Dutch
1 of 19FrankK
Loading description...
Mathematics
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Python (probably other languages also) too: modifying input can influence the random tests: see this
Python (probably other languages also): Proper random tests are required. Solutions like this one should not be possible.
Simple random tests show that either the reference solution is incorrect or the description is incomplete.
What a painful kata! Like it!
It says that I have the ability to edit/approve the kata, but I'm a little reluctant to muck about with approving/editing/creating things. I would like to first get more comfortable wth the established codewars processes, policies, conventions etc. Hence not yet a single kata done by me.
Would any of the power users be so kind as to give me a rundown of what's ok and what's not in terms of editing/approving katas, etc.? Or even just point me to the right documentation perhaps?
https://docs.codewars.com/curating/kata/#review
Hi could you be more descriptive/example for the combinations:
Forming an alliance is a possibility for smaller parties to mitigate their size disadvantage in the assignment of residual seats.
-> OK
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.
-> OK
The votes needed for a seat (quota) is the total votes of the combination divided by the seats assigned to the combination.
-> so if a combination with 100 votes (which correspond to 10 seats) has 2 parties A and B. A who got 70 votes will have 70% of the combination seats (7 seats) and B with 30 votes will get 30% of the combination seats (3 seats). Am I right?
Residual seats are assigned to the parties of a combination based on the largest remainder of votes per seat.
-> I don't understand where the residual seats come from
Hi,
It is always a trade off how much to tell and how much not to tell. You have to do a little more thinking yourself in this kata, just as I had to do when I created it. At least you have the same amount of data as I did because I added a link to a Wiki page in English language.
The residual seats are hard to understand, but interesting. And there are two different mechanisms (that's why I called it 'Double Dutch'):
INITIAL... Let's say that one by one you calculate who is left with the highest average number of votes per seat IF a party (or combination) would get the seat. A party can theoratically get for instance 5 residual seats.
Within a COMBINATION (your question). Here a party can only get 1 residual seat. Seats go to the parties with the highest residue of votes.
Combination example:
Total seats gained by the combination: 10 Allocation:
Then the correct result would be for the combination (1+1+2+4=8 seats allocated immediatly):
I see, that's what I was feeling. It's simply the way to deal with rounding when working with floating numbers.
Few changes I would expect:
OK, but trying to understand the description should never be part of the task.
Yeah, this description is a pain. Also allocating the remaining residual seats after combinations have been handled is a complete mystery. I wanted to solve this kata out of loving memory for Pim, but F it, just not worth it.
Everything you need to know is in the description. Just read better. From my 30 years of experience that is sometimes hard for developers (also when I read the comments here).
And yes, kata is hard. I did the kata myself too and had a problem with it.
Don't patronise me, in my long career I've always challenged bad specs.
You don't want to be patronized?
I tried very very hard to understand what you do not understand. Everything is written down. What is not to understand about the line below? Is it maybe the word 'standard' that you read as 'allocation of seats excluding residual seats'? No clue, the sentence below talks about 'standard allocation' as opposed to 'allocation within combination'.
'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.'
Keep opposing bad specs! You will not find them in this kata.
Hi,
Could you provide in the descriptoin the
votes
data array that leads to the table at the end? Because I have troubles to understand the instructions.thx
Thanks for the kata. I have a quick question. The decriptions says:
What is to be done if a member of a given combination does not reach the "at least 1 seat" standard? Is it simply removed from the combination? If so do it's votes still count toward the combination? Or does the combination dissolve? None of the immediate test cases seem to look at this situation, and maybe it's not important, but I wanted to know before I get too far into addressing that edge case. Thanks
Hi Thom!
At first my respect for you! Nice clean solution. This is not an easy solution :)
You probably already know the answer by now. But the answer is (when creating the kata I also had a problem finding out):
I can declare you an official expert on the Dutch voting system now! ;) I do not a single person who know how it works here in The Netherlands. Just for the record:
Hello Frank,
I actually quite enjoyed the kata, as I like to learn new systems and understand how they work. I'm sure there are very interesting stories as to how the current system came about. I can only imagine the discussions and debate about each step in the process. It's quite intersting to me as an American where we basically get to pick from Column A or Column B for the most part.
As for the Kata, perhaps I'd suggest you just mention you above answer as to how to handle combinations (or mention that no tests will cover this condition, and thus folks can assume all combinations only contain parties that meet the threshold).
I also found this link Wikipedia : Elections In the Netherlands to be helpful in understanding the seat assignments as an outsider. It may come in handy for others as well.
Thanks again for the kata, I enjoyed it. My code is, as per usual for me, not concise or perhaps the most efficient, but I tend toward more verbose code that seems, at least to me, easier to read. Thanks again and cheers.
Hello Thom,
Thanks for your link! I used it in my description.
I find it very interesting, comparing the Dutch system and other systems like the English and American.
Sometimes I get influenced by this website too and try to write also one liners and 1 character variables. But really complex problems, in my humble opinion, can only be solved by well structured and readable code. Cheers!