Created
May 24, 2018 21:30
-
-
Save samueljtaylor/287ae0cf0a2d202a3de989698c123e0d to your computer and use it in GitHub Desktop.
Easy Tally Challenge Solution
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
# https://www.reddit.com/r/dailyprogrammer/comments/8jcffg/20180514_challenge_361_easy_tally_program/ | |
players = {} | |
ARGV[0].split(//).each do |char| | |
name = char.downcase | |
players[name] = 0 if !players[name] | |
players[name] -= 1 if char == char.upcase | |
players[name] += 1 if char == char.downcase | |
end | |
players.sort_by { |index| index[1] }.reverse!.each do |player| | |
print player[0], ': ', player[1], "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment