Is the Doctor’s algorithm truly that fair as the Ood wanted? It appears that those Ood who have low amount of budget must pay it all, and those who are rich pay only a part of it. And more importantly, the more poor Ood participate, the less those who are rich actually contribute.
I wonder if it could be more realistic and fair if the Ood went with percentages (ex., the cost of the gift is 50% of the sum of their budgets => they all have to pay 50%), or even better, using some progressive contribution formulas similar of those used for equity taxation?
Hello, I have an issue with the last big random test and I need some help to debug this please.
The console tells me that the expected output is 70 but it found 69. My last contributor is already giving 70, so it means that a previous contributor should give 70 ?
Maybe you have rounding issues. Suggest you to pull out the input numbers and expected output numbers to take a closer look e.g. in an Excel spreadsheet.
Hi everybody,
could someone helps for issue on “Big Random” . i have quite similar issue than louack, so i look on rounding potential issue. after change that create example 3 + big random as issue so.
in first case only 69 instead of 70 and in second case for big random lot 70 but seems too much.
that really seems as rounding sensitivity but not clear.
Same case, all the tests passed except the last one “Big random”, I’m using Java and I have no issues with rounding, the assertions breaks at the index 529 of the output list where they expect 55 but I gave them 159. I’m still blocked, perhaps my solution logic is wrong, but it did pass the other tests and any case I’m trying.
Hi All, I’m solving the puzzle using Java and I passed all the tests but I failed the last one “Big random”. I tried to debug the output but it’s so long and tedious. I’m suspecting that I have a flaw in my reasoning or a bug in the test.
I checked that I have no problems with rounding because in Java int division returns integers no floating points numbers.
Can any one point the error in my solution that I’ll describe below ?
Suppose we have this use case
3
100
100
10
100
so wee need to distribute 100 on 3 participants,
1- compute the initial distribution and impact amount on the fly as we read the input, an keep the rest
in this case each one is supposed to give 33 but we keep 1 as initial rest
3- start reading from the lowest budget, if it’s overspent, fix it by spending all the available and distribute the exceeding amount over the others
in this case we need to spend 10 and distribute 23 (11 on each), the remaining 1 will be added to the rest
Maybe you can try using a spreadsheet to help you. Copy the input, your output and the expected output to the spreadsheet, and analyse/debug from there.
Naturally participants with the highest budgets contribute more, so it helps by sorting the budgets right at the beginning, instead of after the initial distribution. If you follow this approach, the cost allocated won’t jump from 55 to 159.
Thanks for the response, actually I figured out that my logic was wrong and complicated, I solved the puzzle with the new method in less than 15 minutes.
I created a code that worked part of the time, and then a while latter changed it but that did not work as well. Is there any way I can get my original code back.
I had to lookup a solution to understand what was desired, because my algorithm initially wasn’t ‘greedy’ (yet more fair to everyone that had money to contribute). I now assume ‘greedy’ means that the ‘want’ of the algorithm changes dynamically for each case executed.