Skip to content

Instantly share code, notes, and snippets.

@samueljtaylor
Created May 24, 2018 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueljtaylor/287ae0cf0a2d202a3de989698c123e0d to your computer and use it in GitHub Desktop.
Save samueljtaylor/287ae0cf0a2d202a3de989698c123e0d to your computer and use it in GitHub Desktop.
Easy Tally Challenge Solution
# 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