In a preference ballot there are many ways to decide who won. One of which is the Borda count method, where we give everyone point based on their places on the ballot.
For example, in these results:
10 5 7 2
_____________
1 a d a c
2 b a d b
3 c c b a
4 d b c d
The results are
1: a : 87
2: d : 60
3: b : 55
4: c : 45
Because
4*10 is 40
5*3 is 15
7*4 is 28
2*2 is 4
40 + 15 + 28 + 4 is 87
Or is words: We give first place 4 points , second 3, third 2, etc.
So a
is in first place 17 times, so they get 68 points then they get 15 points for being in second 5 times and 4 points for being in third 2 times for a total of 87 points.
Because this process is a pain, I need you write a program that finds the results for me, but since I have limited space on my PC, your program will have to be as small as possible.
Your Challenge
Write a program or function the takes an input in this format
Number of Ballots : placings, Number of Ballots : placings, Etc...
and will output the results in this format:
1: a: 90
2: b: 80
Etc...
Rules:
This is Code Golf, so the shortest answer that does the task wins
Standard Loopholes Apply
Example:
Input:
3: A B C, 2: C B A, 1: C A B
Output:
1: A: 13
2: C: 12
3: B: 11
This is my first challenge, so please give me all the criticism you so desire, I won't take it offensively.
4*10
comes from. \$\endgroup\$A, B, C...
? How do we handle ties? \$\endgroup\$