-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
29 lines (22 loc) · 920 Bytes
/
index.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
const data = require('./data/powerball_res.json');
const comboGenerator = require('./combo.generator');
const { getProbabilityFromPattern, getNumEven } = require('./pattern.analyser');
const { maxPositions } = require('./config');
const pastResults = data.map(row => row.balls);
const combos = comboGenerator.generateCombinations(data, maxPositions);
// filter out ones with duplicates
const uniqueCombo = combos.filter(combo => {
const pattern = combo.pattern.split(',');
return new Set(pattern).size === pattern.length
});
// pattern analysis
const patternProb = getProbabilityFromPattern(pastResults, maxPositions);
for (const combo of uniqueCombo) {
const even = getNumEven(combo.pattern);
const patternWeight = patternProb[even];
combo.weight *= patternWeight;
}
const sortedCombo = uniqueCombo.sort((a, b) => {
return b.weight - a.weight;
});
console.log(sortedCombo.splice(0, 10));