Created
May 14, 2024 03:40
-
-
Save DrunkenAlcoholic/f7513a5d28c330e4d4b4c34d3fe2fe19 to your computer and use it in GitHub Desktop.
Scrabble Score [Exercism - Nim]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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