Skip to content

Instantly share code, notes, and snippets.

@DrunkenAlcoholic
Created May 14, 2024 03:40
Show Gist options
  • Save DrunkenAlcoholic/f7513a5d28c330e4d4b4c34d3fe2fe19 to your computer and use it in GitHub Desktop.
Save DrunkenAlcoholic/f7513a5d28c330e4d4b4c34d3fe2fe19 to your computer and use it in GitHub Desktop.
Scrabble Score [Exercism - Nim]
import strutils
proc score*(word: string): int =
for char in word.toUpperAscii:
case char
of 'A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T': inc(result)
of 'D', 'G': inc(result, 2)
of 'B', 'C', 'M', 'P': inc(result, 3)
of 'F', 'H', 'V', 'W', 'Y': inc(result, 4)
of 'K': inc(result,5)
of 'J', 'X': inc(result, 8)
of 'Q', 'Z': inc(result, 10)
else: discard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment