Reputation: 129
I'm trying to calculate a total score for a decathlon participant and there are two formulas given, one is for a field events and the other is for track events.
Points = INT(A(B — P)^C) for track events (faster time produces a better score)
Points = INT(A(P — B)^C) for field events (greater distance or height produces a better score
A, B and C are given constants for this formulas and P is the athletes performance measured in seconds (running), metres (throwing), or centimetres (jumping).
Once I am trying to calculate I get a result that is a complex number that I cannot convert into integer or smth like that.
These are the constants for A,B and C : https://en.wikipedia.org/wiki/Decathlon#Points_system
These are my values for athlete's performance (a list that I will try somehow, after adding the total score, convert into a JSON file):
splited_info = ['Lehi Poghos', '13.04', '4.53', '7.79', '1.55', '64.72', '18.74', '24.20', '2.40', '28.20', '6.50.76']
Could someone give me some feedback on what or how am I doing this wrong?
def split(info):
with open(info.filename, "r") as f:
csv_reader = csv.reader(f, delimiter="\n")
for line in csv_reader:
splited_info = line[0].split(";")
score = 0
score += int(25.4347 * ((18 - float(splited_info[1])) ** 1.81))
score += int(0.14354 * ((float(splited_info[2]) - 220) ** 1.4))
score += int(51.39 * ((float(splited_info[3]) - 1.5) ** 1.05))
score += int(0.8465 * ((float(splited_info[4]) - 75) ** 1.42))
score += int(1.53775 * ((82 - float(splited_info[5])) ** 1.81))
score += int(5.74352 * ((28.5 - float(splited_info[6])) ** 1.92))
score += int(12.91 * ((float(splited_info[7]) - 4) ** 1.1))
score += int(0.2797 * ((float(splited_info[8]) - 100) ** 1.35))
score += int(10.14 * ((float(splited_info[9]) - 7) ** 1.08))
score += int(0.03768 * ((480 - float(splited_info[10])) ** 1.85))
print(score)
I'm just hardcoding all the calculations since all the calculations are going to be different with all different values of A,B,C and P.
Upvotes: 4
Views: 399
Reputation: 24201
The problem is a mix up of metres and centimetres. The Wikipedia page is slightly inaccurate in its recount of the formulae - throws are measured in metres but jumps should be measured in centimetres. This is why you're getting fractional powers of negative numbers.
See the original source for more info:
Upvotes: 1