-
-
Save anonymous/65ae37181eec3a3b2765 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
def most_common_letter(string) | |
array = string.split('') | |
new_array = [] | |
array.map do |x| | |
new_array << [x, array.count(x)] | |
array.delete(x) | |
end | |
new_array.sort{|a,b| b[1]<=>a[1]} | |
new_array[0] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment