# Thread: Prize Money/Points Distribution Challenge - Assistance Appreciated

1. ## Prize Money/Points Distribution Challenge - Assistance Appreciated

I'm trying to find the math to calculate prize (money/points) distribution based on some key criteria.
I will be coding the final solution using either C++, not that this is important but the translating to code is a bit.
The prize distribution needs to be logically curved so that 1st gets higher than 2nd etc.
I have shown how I tried to do it however it wasn't scaling due to rounding and having too large a remainder to distribute fairly.
Therefore I feel removing the percentage requirements and grouping, perhaps I can bed it down with simpler rules.

The main variables are...
Total_Entrants (25-100).
Entry_Fee (Whole Number).
Prize_Pool = (Total_Entrants x Entry_Fee) - 10%
Winners - Prize_Pool to be distributed to top 50% with remainder going to 1st (if required).
- Winners is rounded up if an odd number. Bottom 50% get nothing.

---------------------------------------------

Previously I have tried basing it on grouping Total_Entrants like so...
1-10% get 50% of Prize_Pool
11-20% get 2% of Prize_Pool
21-30% get 1.5% of Prize_Pool
31-40% get 1% of Prize_Pool
41-50% get 0.5% of Prize_Pool

So I was doing this;
Total_Entrants = 100
Entry_Fee = 5.50
Discount = 10;

Total_Entrants * Entry_Fee = Total_Price
100 * 5.50 = 550

Total_Price - (Total_Price * (Discount/100)) = Prize_Pool
550 - (550 * (10/100)) = 500

Then I would split Prize_Pool
500/2 = 250

Calculate Groups
Total_Entrants/10 = Group_Number
100/10 = 10 (groups of 10)

Allocate bottom half of Prize_Pool to lower brackets as per above percentages, which works out perfectly.
11-20 = 2% x (100/Total_Entrants) x Prize_Pool = Prize_Group2
2% x 1 x 500 = 10
21-30 = 1.5% x (100/Total_Entrants) x Prize_Pool = Prize_Group3
1.5% x 1 x 500 = 7.5
31-40 = 1%% x (100/Total_Entrants) x Prize_Pool = Prize_Group4
1% x 1 x 500 = 5
41-50 = 0.5% x (100/Total_Entrants) x Prize_Pool = Prize_Group5
0.5% x 1 x 500 = 2.5
This all adds up to 50%

Then for the Top 10%, I calculated a value for N. Calculating the value 30 I had a little help so can't expand on that.
N = 30/(SUM of player index count)% of Prize_Pool
N = 30/(1+2+3+4+5+6+7+8+9+10)% of 500
N = 30/55% of 500
N = 0.5454545% of 500 = 2.7272725
Rounded this value up to 3 therefore N = 3

Then I calculated top 10 like so...
1 = 2% + 10N = 40
2 = 2% + 9N = 37
3 = 2% + 8N = 34
4 = 2% + 7N = 31
5 = 2% + 6N = 28
6 = 2% + 5N = 25
7 = 2% + 4N = 22
8 = 2% + 3N = 19
9 = 2% + 2N = 16
10 = 2% + N = 13

This all added up exactly the problem was the scaling due to rounding the groups and the value of N.
It worked sweet for 100, 90, 80, 70, 60, 50 but started finding issues due to rounding.
I actually had it rounding perfectly however values from 91-99, 81-89 etc. ended up with a remainder which stopped me in my tracks.

I couldn't find a solution so thought why not start from scratch without the percentages and group classification being so strict.
I have a lot more workings etc. but thought someone here had an idea on where to start.

2. ## Re: Prize Money/Points Distribution Challenge - Assistance Appreciated

The method above seems to be doing these steps in order:
* Allocating people into brackets
* Distributing the prize pool to brackets, then for each bracket, distributing to people.

I would instead proceed in the opposite direction. That is:
* Distribute prize money to winners in descending order. Round down, with maximum precision of cents. (I would argue prizes are in multiples of $10, and should be rounded down to the nearest$10). I round down so it's not possible to exceed the amount needed to pay out, plus I think this is the way to resolve currencies with additional precision in real life. ie. I can't give 0.001 dollars and a prize of 1234.56 isn't very common)
* Group these winners into brackets to aggregate totals as desired.

Winners = Total_Entrants / 2 (I mean / in programming language C. ie. 9/4 = 2)
Prize_Pool should be = ROUND((Total_Entrants x Entry_Fee) - 10%) * 0.5) ((You said you're dividing the prize pool by half to distribute to the top winners, but this means my expression to the left is actually the amount to be distributed among winners))

You can then implement a loop to calculate Amounts to distribute. ex. To create 3 amounts, you might just have a list of percentages (50%, 25%, 10%) and loop over it.

Then you could implement a function to group the winners into brackets. It could be as simple as Top Bracket is a fixed number of people, with other brackets being evenly distributed, except in the case of 1 remaining person to be placed at the bottom bracket.
Then for each bracket, aggregate the amounts from each winner in those brackets for a bracket total.

If you were to graph the winners from highest to lowest earning on the x axis, and winnings on the y-axis, it should look like a bar graph with bar height lower than a negative exponential curve (or similar - always decreasing with a limit of 0) whose area is equal to prize pool amount. (ie. It's a lower estimate)