Created
December 12, 2011 17:11
-
-
Save onewland/1468226 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
$points = {} | |
def points(array, val) | |
array.each do |x| | |
$points[x] = val | |
end | |
end | |
points(%w{A E I L N O R S T U}, 1) | |
points(%w{D G}, 2) | |
points(%w{B C M P}, 3) | |
points(%w{F H V W Y}, 4) | |
$points['K'] = 5 | |
points(%w{J X}, 8) | |
points(%w{D G}, 7) | |
points(%w{Q Z}, 10) | |
def word_score(w) | |
w.chars.map { |c| $points[c] }.reduce(:+) | |
end | |
puts word_score('STINKER') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment