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.98 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.97 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.96 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.95 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.94 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.93 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.92 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.91 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.90 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.89 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.88 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.87 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.86 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.85 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.84 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.83 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.82 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.81 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.80 tracks/scala/exercises/scrabble-score/example.scala
trackler-2.2.1.79 tracks/scala/exercises/scrabble-score/example.scala