Skip to content

Instantly share code, notes, and snippets.

@alxfv
Last active December 11, 2015 12:58
Show Gist options
  • Save alxfv/4604329 to your computer and use it in GitHub Desktop.
Save alxfv/4604329 to your computer and use it in GitHub Desktop.
hw1-1
def palindrome?(str)
str.downcase.gsub(/\W/, '') == str.downcase.gsub(/\W/, '').reverse
end
def count_words(str)
words = {}
str.downcase.split(/\W+/).each do |word|
words[word] = words.include?(word) ? words[word] + 1 : words[word] = 1
end
words
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment