-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (19 loc) · 695 Bytes
/
Copy pathindex.js
File metadata and controls
24 lines (19 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const getLetterFrequencies = require("./helpers/getLetterFrequencies");
const calculateWordScores = require("./helpers/calculateWordScores");
const sortKeysByValue = require("./helpers/sortKeysByValue");
const words = require("./dict.json");
const frequencies = getLetterFrequencies(words);
const lettersSortedByFrequency = sortKeysByValue(frequencies);
const wordScores = calculateWordScores(words, frequencies);
const wordsSortedByValue = sortKeysByValue(wordScores);
console.log(
"Letters sorted by frequency: \n",
lettersSortedByFrequency.join(", "),
"\n"
);
console.log(
"Best words: \n",
// only show the top 20 words
wordsSortedByValue.slice(0, 20).join(", "),
"\n"
);