6 kyu

Coding 3min : Excel Puzzle #2

76 of 104myjinxin2015

Description:

This is the simple version of Fastest Code series. If you need some challenges, please try the Performance version

Task:

You are given two arguments: excel(number array), like this:[1 ,2 ,3 ,4 ,5 ,6], and n(an index of target number)

Return the rank of excel[n].

The rank means, when excel in ascending order, what is its position.

In this simple version, excel length range: 5...99, elements of excel value range: 0...99

Some example to help you understand the rules:


(       [1,2,3,4,5], 0) => 1
rank:    1 2 3 4 5
[0]=1, rank of number 1 is 1

(       [1,2,3,4,5], 1) => 2
rank:    1 2 3 4 5
[1]=2, rank of number 2 is 2

(       [5,4,3,2,1], 0) => 5
rank:    5 4 3 2 1
[0]=5, rank of number 5 is 5

(       [5,4,3,2,1], 1) => 4
rank:    5 4 3 2 1
[1]=4, rank of number 4 is 4

so easy? see other examples:

(       [1,2,2,2,3], 1) => 2
rank:    1 2 3 4 5
the same number have different ranks,
the number of smaller indexes is in front of others.
[1]=2, rank of first number 2 is 2

(       [1,2,2,2,3], 2) => 3
rank:    1 2 3 4 5
[2]=2, rank of second number 2 is 3

(       [2,2,2,2,2], 2) => 3
rank:    1 2 3 4 5
[2]=2, rank of 3rd number 2 is 3


Please use the sort function carefully, because the original array should not be changed.

Series:

Puzzles
Games

Stats:

CreatedApr 25, 2016
PublishedApr 25, 2016
Warriors Trained260
Total Skips2
Total Code Submissions589
Total Times Completed104
JavaScript Completions76
Python Completions36
Total Stars2
% of votes with a positive feedback rating88% of 45
Total "Very Satisfied" Votes38
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes4
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • ZED.CWT Avatar
  • user9644768 Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad