The decathlon is a combined event in athletics consisting of ten track and field events. The word decathlon is of Greek origin, from δέκα (déka, meaning "ten") and ἄθλος (áthlos, or ἄθλον, áthlon, meaning "feat"). The decathlon is mainly contested by male athletes, while female athletes typically compete in the heptathlon.

decathlon
A decathlon combines four runs, three jumps and three throws.

All events of a decathlon are held over two consecutive days and the winners are determined by the combined performance in all. Performance is judged on a points system in each event, not by the position achieved. The point system uses three parameters $$a$$, $$b$$ and $$c \in \mathbb{R}^{+}$$ that vary by discipline. A performance $$p$$ for a given discipline is scored using the following formulae:

The notation $$\left \lfloor{x}\right \rfloor \in \mathbb{N}$$ denotes the integer part of $$x \in \mathbb{R}^{+}$$ and the performance $$p$$ by the athlete for a given discipline is measured in seconds (running), meters (throwing) or centimeters (jumping). The Olympic decathlon, for example, uses the parameters in the following table:

discipline $$a$$ $$b$$ $$c$$
100 m 25.4347 18 1.81
long jump 0.14354 220 1.4
shot put 51.39 1.5 1.05
high jump 0.8465 75 1.42
400 m 1.53775 82 1.81
110 m hurdles 5.74352 28.5 1.92
discus throw 12.91 4 1.1
pole vault 0.2797 100 1.35
javelin throw 10.14 7 1.08
1500 m 0.03768 480 1.85

Traditionally, the title of "World's Greatest Athlete1" has been given to the man who wins the Olympic decathlon. This began when King Gustav V of Sweden told Jim Thorpe, "You, sir, are the world's greatest athlete" after Thorpe won the decathlon at the Stockholm Olympics in 1912. The current decathlon world record holder is American Ashton Eaton, who scored 9045 points at the 2015 IAAF World Championships.

Assignment

In this assignment we will process two types of text files that both have lines containing comma-separated fields. Text files containing parameters for disciplines define the parameters that are used to compute the score for a series of disciplines. Each line contains the name of a discipline, the parameters $$a$$, $$b$$ en $$c \in \mathbb{R}^{+}$$, and a field containing the text yes for track events and no for field events. For the disciplines of the decathlon, such a text file might look like this.

100 m,25.4347,18,1.81,yes
long jump,0.14354,220,1.4,no
shot put,51.39,1.5,1.05,no
high jump,0.8465,75,1.42,no
400 m,1.53775,82,1.81,yes
110 m hurdles,5.74352,28.5,1.92,yes
discus throw,12.91,4,1.1,no
pole vault,0.2797,100,1.35,no
javelin throw,10.14,7,1.08,no
1500 m,0.03768,480,1.85,yes

Text files containing performances for disciplines define the performances of an athlete in a combined event in athletics (a decathlon or a heptathlon, for example). Each line contains the name of a discipline and the performance of the athlete for that discipline. Performances are expressed in seconds (running), meters (throwing) or centimeters (jumping). For a sequence of extremely good performances for the disciplines of the decathlon (all current world records for each of the individual disciplines) the text file might look like this.

100 m,9.58
long jump,895
shot put,23.12
high jump,245
400 m,43.18
110 m hurdles,12.87
discus throw,74.08
pole vault,614
javelin throw,98.48
1500 m,206.00

Your task:

Example

The following interactive session assumes that the text files parameters.txt2 and performances.txt3 are located in the current directory.

>>> params = parameters('parameters.txt')
>>> params['100 m']
(25.4347, 18.0, 1.81, True)
>>> params['pole vault']
(0.2797, 100.0, 1.35, False)

>>> score('100 m', 9.58, params)
1202
>>> score('pole vault', 614, params)
1277
>>> score('scuba diving', 614, params)
Traceback (most recent call last):
AssertionError: invalid discipline

>>> finalScore('performances.txt', 'parameters.txt')
12544