Sha256: 04d6f07769a7ceeea86f017b163c7e0208203247f060c091607d7e8538920ba9

Contents?: true

Size: 688 Bytes

Versions: 66

Compression:

Stored size: 688 Bytes

Contents

module ScrabbleScore exposing (scoreWord)

import String exposing (contains, foldl, fromChar, toUpper)


addLetterScore : Char -> Int -> Int
addLetterScore s total =
    let
        c =
            toUpper (fromChar s)
    in
    if contains c "AEIOULNRST" then
        total + 1
    else if contains c "DG" then
        total + 2
    else if contains c "BCMP" then
        total + 3
    else if contains c "FHVWY" then
        total + 4
    else if contains c "K" then
        total + 5
    else if contains c "JX" then
        total + 8
    else if contains c "QZ" then
        total + 10
    else
        total


scoreWord : String -> Int
scoreWord x =
    x |> foldl addLetterScore 0

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.179 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.178 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.177 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.176 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.175 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.174 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.173 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.172 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.171 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.170 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.169 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.167 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.166 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.165 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.164 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.163 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.162 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.161 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm
trackler-2.2.1.160 tracks/elm/exercises/scrabble-score/ScrabbleScore.example.elm