Swimming

The coach of the woman’s Catalan team of synchronized swimming wants to assess the performance of its elite athletes. Each swimmer has completed 3 full tests in this quarter and each test has a maximum score of 10 points. The final mark of the athletes takes into account these three scores and the following rules:

  • If the swimmer has not pass one or more tests (score less than 5 points) then the final mark is 0 points (disqualified).

  • If the swimmer has passed all three tests then the basic final mark is computed as the integer part of the arithmetic mean of the three individual scores. This basic final mark can be improved by applying the two next rules.

  • If the swimmer has passed all three tests and the three scores are a monotonically increasing sequence (meaning that she has made good progress) then an additional point is added to the basic final mark.

  • Moreover, if the swimmer has passed all three tests, an additional point is given for each score equal to 10 points (maximum 3 points).

Therefore, the maximum possible final mark is 14 points: when the three individual scores are 10 points (average 10 points + 1 point of progress + 3 points, one for each score of 10 points).

Write the function mark() that takes three integers corresponding to the three mentioned scores of a swimmer in chronological order, and returns her final mark (integer) computed using the previous rules.

Save this function into a file named swimming.py.

See the following examples:

>>> mark(4, 5, 6)
0
>>> mark(7, 8, 7)
7
>>> mark(6, 6, 8)
7
>>> mark(10, 8, 6)
9
>>> mark(7, 10, 10)
12
>>> mark(10, 10, 10)
14

Note

More tests are provided in the test-swimming.txt file.

Solution

A solution is provided in the swimming.py file.