JX QZ} .zip([1, 2, 3, 4, 5, 8, 10]) .flat_map {|letters, score| letters.chars.product([score])} .to_h def initialize(chars) letters = chars.to_s.upcase.scan(/\w/) # ["T", "A", "M", "A", "R", "B"] @sum = letters.sum(&SCORE) end def score @sum end def self.score(chars) self.new(chars).score end end p Scrabble.new("tamarb") 16