Sha256: 282688afb2cacaa3bbc2e03cbddebe086bbcd1f10cc45f735d01e5ab97e4d4ab

Contents?: true

Size: 395 Bytes

Versions: 37

Compression:

Stored size: 395 Bytes

Contents

import tables, sequtils, strutils, math

let points = {
    'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1,
    'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
    'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1,
    'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
    'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4,
    'z': 10
}.toTable

proc score*(word: string): int =
    sum(word.toLowerAscii.map(proc(x: char): int = points[x]))

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
trackler-2.2.1.172 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.171 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.170 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.169 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.167 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.166 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.165 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.164 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.163 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.162 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.161 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.160 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.159 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.158 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.157 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.156 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.155 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.154 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.153 tracks/nim/exercises/scrabble-score/example.nim
trackler-2.2.1.152 tracks/nim/exercises/scrabble-score/example.nim