Skip to content

Instantly share code, notes, and snippets.

@onewland
Created December 12, 2011 17:11
Show Gist options
  • Save onewland/1468226 to your computer and use it in GitHub Desktop.
Save onewland/1468226 to your computer and use it in GitHub Desktop.
$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