Skip to content

Instantly share code, notes, and snippets.

@kiefer136
Last active March 30, 2016 23:31
Show Gist options
  • Save kiefer136/e46bf4c602e631bc2d433ffbe105214e to your computer and use it in GitHub Desktop.
Save kiefer136/e46bf4c602e631bc2d433ffbe105214e to your computer and use it in GitHub Desktop.
character counting
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