Skip to content

Instantly share code, notes, and snippets.

@techsin
Created July 30, 2015 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techsin/d03e2a0cde77923b9249 to your computer and use it in GitHub Desktop.
Save techsin/d03e2a0cde77923b9249 to your computer and use it in GitHub Desktop.
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