0

I have been trying to build the Borda count in Python for a few days. I have done quite a lot of work on internet searching as well. All of the examples I have found so far is the Borda count for text (e.g input = ['A>B>C>D=E']), which is different from my input.

For my program, I want create the Borda count function which requires an input as a list of numbers. e.g.

input = [5, 1 ,2, 1, 3]

Then, the function should be able to calculate scores as;

output = [4, 0.5, 2, 0,5, 3]

If anyone has some idea or examples of similar code, Could you please help me out of this problem.

Thanks a lot

Francisco
  • 10,918
  • 6
  • 34
  • 45
June
  • 1
  • 2
  • 1
    Are you able to explain how, given the input values you wind up with the output values? What is the math? – Bartek R. Nov 05 '16 at 04:29
  • Sorry, I didn't make it clear. If we have 5 numbers (n), Borda count will give the highest score, which is equal to 4 (n-1), to the maximum value. Then decrease score by 1 for the next maximum value. For example, if input = [1,2,3,4,5], output will be [0,1,2,3,4]. In my case, input = [5, 1, 2, 1, 3] the output should be [4, 0.5, 2, 0.5, 3] since the first input value is the maximum (5), it got 4 (the first position in the output). The next highest value is 3, which is in the last position in the input so, it got output score 3. Position 2,5 are equal, which are 1, so they share scores. – June Nov 06 '16 at 11:54
  • By the way, I have just done the coding. It works as I want but not very nice looking code. Actually, I tried to post my code but it didn't let me. It show as my code is in the wrong format. If anyone has the same problem, please feel free to contact me. I will send it to you. Thanks a lot Rojas :-) – June Nov 06 '16 at 12:02

0 Answers0