6 kyu

Rank Vector

757 of 2,163rtoal

Description:

Given an array (or list) of scores, return the array of ranks for each value in the array. The largest value has rank 1, the second largest value has rank 2, and so on. Ties should be handled by assigning the same rank to all tied values. For example:

  • array = [9,3,6,10] --> ranks = [2,4,3,1]

  • array = [3,3,3,3,3,5,1] --> ranks = [2,2,2,2,2,1,7]

    because there is one 1st place value, a five-way tie for 2nd place, and one in 7th place.

Arrays
Sorting
Algorithms

More By Author:

Check out these other kata created by rtoal

Stats:

CreatedNov 9, 2014
PublishedNov 9, 2014
Warriors Trained3953
Total Skips281
Total Code Submissions11643
Total Times Completed2163
JavaScript Completions757
Python Completions1042
Haskell Completions142
Ruby Completions161
Rust Completions43
C# Completions81
Julia Completions13
Lua Completions27
C Completions18
Total Stars81
% of votes with a positive feedback rating93% of 349
Total "Very Satisfied" Votes307
Total "Somewhat Satisfied" Votes35
Total "Not Satisfied" Votes7
Ad
Contributors
  • rtoal Avatar
  • jhoffner Avatar
  • tko Avatar
  • GiacomoSorbi Avatar
  • Voile Avatar
  • NunoOliveira Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • sid114 Avatar
  • NikCSharp Avatar
Ad