Learning Dart

This commit is contained in:
2023-04-06 11:35:43 -05:00
parent fab045379a
commit b16a5813cc
92 changed files with 6437 additions and 21 deletions

View File

@@ -0,0 +1,18 @@
class ScrabbleScore {
Map letterScores = Map<rune, int>.of({
'a': 1, 'e': 1, 'i': 1, 'o': 1, 'u': 1, 'l': 1, 'n': 1, 'r': 1, 's': 1, 't': 1,
'd': 2, 'g': 2,
'b': 3, 'c': 3, 'm': 3, 'p': 3,
'f': 4, 'h': 4, 'v': 4, 'w': 4, 'y': 4,
'k': 5,
'j': 8, 'x': 8,
'q': 10, 'z': 10
});
int score(String word) {
word = word.toLowerCase();
int ret = 0;
word.runes.forEach(r => ret += letterScores[r]);
return ret;
}
}