Created
July 30, 2015 16:05
-
-
Save techsin/d03e2a0cde77923b9249 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
sentence = <<-something | |
Steven likes the movies. Blake likes to ride his bike but hates movies. | |
Blake is taller than than than steven. Steven Steven is a great teacher. | |
something | |
counter = Hash.new(0) | |
sentence.gsub!(".","").split(" ").each do |word| | |
counter[word] += 1 | |
end | |
cost = {} | |
words = counter.map { |k,v| cost[k] = k.chars.map(&:downcase).map {|x| x.ord-96 }.inject(&:+)*v if v>2 } | |
puts cost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment