-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpackage.js
57 lines (45 loc) · 1.5 KB
/
package.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
const fs = require('fs');
function processPos(pos) {
if (!pos.result) {
return {
guess: pos.guess,
next: oMap(pos.next, processPos)
};
}
if (pos.result == '✅ SUCCESS') {
if (pos.sols.length == 1) {
return pos.sols[0];
}
return {
guessesLeft: pos.guessesLeft,
possibilities: pos.sols
}
}
throw new Error(pos.result);
}
function oMap(obj, cb) {
const out = {};
for (const k in obj) out[k] = cb(obj[k], k);
return out;
}
function write(fn, pos) {
fs.writeFileSync(`${fn}.json`, JSON.stringify(pos, null, 2));
}
write('easy', processPos(require('./out/results.json')));
const hard = require('./hard/results.json');
function patch(replacement, ...results) {
const last = results.pop();
let target = hard;
for (const r of results) target = target.next[r];
const newPos = require('./' + target.next[last].path + '/results-' + replacement + '.json');
// target.guess = replacement;
// console.log({target, newPos, replacement, results, last})
target.next[last] = newPos;
// console.log(target);
}
patch('dated', '⬛️⬛️🟨⬛️⬛️', '🟨⬛️⬛️🟨⬛️');
patch('dampy', '⬛️⬛️🟨⬛️⬛️', '🟨⬛️⬛️⬛️⬛️', '⬛️🟩⬛️⬛️🟩');
patch('tsadi', '⬛️⬛️🟩⬛️🟨', '⬛️⬛️🟩🟨🟨');
patch('woker', '⬛️⬛️⬛️⬛️⬛️', '⬛️🟨⬛️⬛️⬛️', '⬛️⬛️⬛️🟩🟩');
patch('purin', '⬛️⬛️⬛️⬛️⬛️', '⬛️⬛️🟨⬛️🟨');
write('hard', processPos(hard));