Skip to content

Commit

Permalink
[Scrabble Score]: Simplify example (#526)
Browse files Browse the repository at this point in the history
* Simplify example

* Format files
  • Loading branch information
meatball133 authored Oct 14, 2023
1 parent d9fa5d7 commit afa4cde
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions exercises/practice/scrabble-score/.meta/src/example.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ScrabbleScore
extend self

@@scores = {
SCORES = {
'A' => 1, 'E' => 1, 'I' => 1, 'O' => 1, 'U' => 1, 'L' => 1,
'N' => 1, 'R' => 1, 'S' => 1, 'T' => 1, 'D' => 2, 'G' => 2,
'B' => 3, 'C' => 3, 'M' => 3, 'P' => 3, 'F' => 4, 'H' => 4,
Expand All @@ -10,6 +10,6 @@ module ScrabbleScore
} of Char => Int32

def score(word : String) : Int32
word.upcase.chars.map { |c| @@scores[c] }.sum(0)
word.upcase.chars.map { |c| SCORES[c] }.sum
end
end

0 comments on commit afa4cde

Please sign in to comment.