Skip to content

Instantly share code, notes, and snippets.

@stupeters187
Created March 30, 2016 18:23
Show Gist options
  • Save stupeters187/0216ac627cf359f17bd6a7855437ed17 to your computer and use it in GitHub Desktop.
Save stupeters187/0216ac627cf359f17bd6a7855437ed17 to your computer and use it in GitHub Desktop.
require 'pry'
def count_letters(string)
letter_hash = Hash.new(0)
# string.each do |chars|
string.split('').each do |i|
letter_hash[i] += 1
end
# end
letter_hash
end
puts count_letters("lighthouse")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment