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.0.5 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.0.4 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.0.3 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.0.2 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.0.1 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.0.0 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.55 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.54 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.53 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.52 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.51 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.50 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.49 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.48 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.47 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.46 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.45 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.44 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.43 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.1.0.42 tracks/scala/exercises/scrabble-score/example.scala