-
-
Save thedjinn/830163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We have four scores, two of them share the second place. This means the last | |
# one has to be pushed to the fourth place. | |
scores = [10, 9, 9, 8] | |
ranking, last_score, add = 0, 0, 1 | |
rankings = scores.map do |score| | |
scores.index(score) + 1 | |
end | |
puts scores.inspect # => [10, 9, 9, 8] | |
puts rankings.inspect # => [1, 2, 2, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment