Guest User

Untitled

a guest
Jul 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. # We have four scores, two of them share the second place. This means the last
  2. # one has to be pushed to the fourth place.
  3.  
  4. scores = [10, 9, 9, 8]
  5.  
  6. ranking, last_score, add = 0, 0, 1
  7.  
  8. rankings = scores.map do |score|
  9. scores.index(score) + 1
  10. end
  11.  
  12. puts scores.inspect # => [10, 9, 9, 8]
  13. puts rankings.inspect # => [1, 2, 2, 4]
Add Comment
Please, Sign In to add comment