Skip to content

Instantly share code, notes, and snippets.

@CharlesFainLehman
Created September 11, 2010 18:41
Show Gist options
  • Save CharlesFainLehman/575432 to your computer and use it in GitHub Desktop.
Save CharlesFainLehman/575432 to your computer and use it in GitHub Desktop.
@values = {"a" => 1, "b" => 3, "c" => 3, "d" => 2, "e" => 1, "f" => 4, "g" => 2, "h" => 4, "i" => 1, "j" => 8, "k" => 5, "l" => 1, "m" => 3, "n" => 1, "o" => 1, "p" => 3, "q" => 10, "r" => 1, "s" => 1, "t" => 1, "u" => 1, "v" => 4, "w" => 4, "x" => 8, "y" => 4, "z" => 10}
def getChar(c)
@values[c.downcase]
end
def getWord(w)
sum = 0
w.each_char do |c|
sum += getChar c unless getChar(c).nil?
end
sum
end
print "enter word: "
puts getWord gets.strip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment