This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.twoFaces.js
81 lines (76 loc) · 2.12 KB
/
app.twoFaces.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const fs = require("fs");
const path = require("path");
debugger;
const dictionary = fs.readFileSync(
path.join(__dirname, "wordlist.10000"),
"utf8"
);
function prepareDictionary(dictionary) {
let fourLetterWordList = [];
const dictionaryArray = dictionary.split("\n");
for (let i = 0; i < dictionaryArray.length; i++) {
if (dictionaryArray[i].length === 4) {
fourLetterWordList.push(dictionaryArray[i]);
}
}
return fourLetterWordList;
}
function splitWord(word) {
// console.log(word);
return word.toLowerCase().split(""); // now it should look like ['d', 'a', 'v', 'e']
}
function main() {
let result = [];
const wordList = prepareDictionary(dictionary);
for (let i = 0; i < wordList.length; i++) {
let topLevelWord = wordList[i];
let topLevelWordArray = splitWord(topLevelWord);
var A1 = topLevelWordArray[0];
var B1 = topLevelWordArray[1];
var C1 = topLevelWordArray[2];
var D1 = topLevelWordArray[3];
for (let x = 0; x < wordList.length; x++) {
let nestedWord = wordList[x];
let nestedWordArray = splitWord(nestedWord);
let E1 = nestedWordArray[0];
let F1 = nestedWordArray[1];
let G1 = nestedWordArray[2];
let H1 = nestedWordArray[3];
let newWordOne = B1 + A1 + E1 + F1;
let newWordTwo = C1 + D1 + H1 + G1;
if (wordList.includes(newWordOne) && wordList.includes(newWordTwo)) {
result.push([newWordOne, newWordTwo]);
}
}
fs.writeFileSync("./result.csv", JSON.stringify(result));
}
return result.length;
}
let totalValues = main();
console.info(totalValues);
// const arrayNumberedFaces = [
// [A1, B1, C1, D1],
// [E1, F1, G1, H1],
// [A4, B4, C4, D4],
// [E2, F2, G2, H2],
// [F3, E3, A3, B3],
// [G3, H3, D3, C3],
// [B1, A1, E1, F1],
// [C1, D1, H1, G1],
// [E3, F3, G3, H3],
// [A3, B3, C3, D3],
// [E4, F4, G4, H4],
// [A2, B2, C2, D2],
// [B5, A5, E5, F5],
// [C5, D5, H5, G5],
// [C6, D6, H6, G6],
// [B6, A6, E6, F6],
// ];
// const arrayLettersOnly = [
// [A, B, C, D],
// [E, F, G, H],
// [F, E, A, B],
// [G, H, D, C],
// [B, A, E, F],
// [C, D, H, G],
// ]