6 kyu

Climbers Rankings

133 of 285lucky3

Description:

International Federation of Sports Climbing (ISFC) hired You to create "Rank Calculator". Climbers get points for each competition they attend, if they are in the top 30 (1st gets 100, 2nd: 80, 3rd: 65, 4th: 55, 5th: 51,...).

Overall rankings are calculated by summing the best 6 results for each climber respectively. If climber has less than 6 results, existing ones are taken.

#Task: Create GetRankings function, that will take collection of climbers' names with their results, and return collection of climbers' names and sum of their best 6 results. Returned collection should be ordered by sum of results in descending order. With other words: climber with highest sum of points should be first, climber with lowest sum of points should be last.

#Example:

Input: [{"John Anonymous", [100, 80, 40]}, {"Mike TheSecond", [20, 22, 24, 26, 28, 30, 100, 100, 100]}]
Output: [{"Mike TheSecond", 384}, {"John Anonymous", 220}]
Input:  [{"name":"SKOFIC Domen", "points":[55, 100, 100, 25, 100, 51, 80]}, {"name":"SCHUBERT Jakob", "points":[80, 80, 40, 47, 65, 100, 65, 37]}]
Output: [{"name":"SKOFIC Domen", "points":486}, {"name":"SCHUBERT Jakob", "points":437}]

Notes

  • Not every climber attended all competitions (there can be less than 6 results for climber).
  • Only best 6 results are summed at maximum.
Arrays
Fundamentals

More By Author:

Check out these other kata created by lucky3

Stats:

CreatedAug 28, 2016
PublishedAug 28, 2016
Warriors Trained621
Total Skips37
Total Code Submissions1250
Total Times Completed285
C# Completions133
JavaScript Completions159
Total Stars12
% of votes with a positive feedback rating85% of 96
Total "Very Satisfied" Votes76
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes8
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • lucky3 Avatar
  • smile67 Avatar
  • hobovsky Avatar
  • LosBlobbos Avatar
Ad