Last active
March 30, 2016 23:31
-
-
Save kiefer136/e46bf4c602e631bc2d433ffbe105214e to your computer and use it in GitHub Desktop.
character counting
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 count_letters(string) | |
letters = Hash.new(0) | |
string_split = string.split('') | |
for x in string_split do | |
if x != ' ' | |
letters[x] += 1 | |
end | |
end | |
letters | |
end | |
p count_letters("Lighthouse Labs in the okanagan") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment