Last active
December 26, 2015 02:19
-
-
Save bryanaknight/7077604 to your computer and use it in GitHub Desktop.
Scrabble
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
class Scrabble | |
def initialize | |
SCORES = {"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} | |
end | |
def self.score(word) | |
SCORES[word.upcase] | |
end | |
end | |
gem 'minitest' | |
require './lib/scrabble' | |
require 'minitest/autorun' | |
require 'minitest/pride' | |
class ScrabbleTest < Minitest::Test | |
def test_it_can_score_a_single_letter | |
assert_equal 1, Scrabble.score("a") | |
assert_equal 4, Scrabble.score("f") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment