6 kyu

Decathlon World Championship

67 of 87zruF

Description:

Decathlon World Championship

The Decathlon World Championship is back and you have determine who the winner is!

In Decathlon there are 10 different disziplines and there are two different formulas to calculate the points of each discipline.

  • Points = INT(A * (B - P) ** C) for track events (faster time produces a better score) - 100m, 400m, 1500m, 110m hurdles
  • Points = INT(A * (P - B) ** C) for field events (greater distance or height produces a better score) - Long jump, Shot put, High jump, Discus throw, Pole Vault, Javelin throw

Where P is the performance of the athlete.

The units of P in the disciplines:

Seconds - 100m, 400m, 1500m, 110m hurdles
centimeter - Long Jump, High Jump, Pole Vault
meter - Shot put, Discus Throw, Javelin Throw

There is a preloaded Object with the name pTable with the parameters of A, B and C for each diszipline.

Notes:

  • You will get an object with at least two athletes and their performance in each discipline.
  • In C# you will get an array with Athletes objects with the properties Name {string} and Disciplines {Dictionary(string, double)}
  • You have to calculate the total amount of points for each athlete and return the name of the winner!
  • You have to floor each amount of points for every discipline in the calculation.
  • Some Atheletes doesn't perform in every discipline, so the performance for this specific discipline would be null (javascript) and 0 (C#) => 0 points for this discipline
  • If a athlete is too bad to get any points, he will receive 0 points. This is the minimum. There aren't negative points. An athlete does not get any points if the term, respectively (B — P) or (P — B), is negative.
  • The unit of each discipline is correct in the input object.
  • The names of the disciplines in pTable are the same as in the input object.
  • No need to check for invalid input!

e.g:

 

  var athletes = {
                  "Bob": {"100m": 12.3, "Long jump": 530, "Shot put": 9.4, "High jump": 160, "400m": 59.6, "110m hurdles": 19.2, "Discus throw": 23, "Pole vault": 270, "Javelin throw": 19, "1500m": 300.5 },
                  "Fred": {"100m": 11.9, "Long jump": 500, "Shot put": 9.4, "High jump": 150, "400m": 59.6, "110m hurdles": 19.2, "Discus throw": 19, "Pole vault": 320, "Javelin throw": 19, "1500m": 300.5 }
               }
               
  decathlon(athletes) => "Fred";

 
Algorithms

Similar Kata:

Stats:

CreatedAug 7, 2017
PublishedAug 7, 2017
Warriors Trained398
Total Skips23
Total Code Submissions1447
Total Times Completed87
JavaScript Completions67
C# Completions24
Total Stars8
% of votes with a positive feedback rating84% of 31
Total "Very Satisfied" Votes21
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • zruF Avatar
  • myjinxin2015 Avatar
  • hobovsky Avatar
  • dfhwze Avatar
Ad