Sha256: 6bf121e8ec2aac51ef6e667121ca42d24033f0322c139e65669be369e7b46043

Contents?: true

Size: 445 Bytes

Versions: 200

Compression:

Stored size: 445 Bytes

Contents

object ScrabbleScore {

  def score(word: String): Int = word.foldLeft(0)((score, c) => score + scoreLetter(c))

  def scoreLetter(c: Char): Int = letterScores.getOrElse(c.toUpper, 0)

  private val scores = List(("AEIOULNRST", 1), ("DG", 2), ("BCMP", 3), ("FHVWY", 4),
    ("K", 5), ("JX", 8), ("QZ", 10))

  private val letterScores: Map[Char, Int] =
    scores.flatMap({case (letters, score) => for {c <- letters} yield (c, score)}).toMap
}

Version data entries

200 entries across 200 versions & 1 rubygems

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