-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (43 loc) · 866 Bytes
/
index.js
File metadata and controls
51 lines (43 loc) · 866 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
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
const sra = require('./stable-roommates-algorithm')
const utils = require('./utils')
const completePrefs = [
[1,3,5,2,4],
[3,4,5,0,2],
[3,4,5,0,1],
[5,2,0,4,1],
[5,2,3,1,0],
[0,1,3,2,4]
]
const partialPrefs = [
[1,16,14],
[0,12,14],
[10,11,14],
[13,16,5],
[5,12,17],
[4,7,8],
[4,9,2],
[17,8,9],
[6,11,1],
[16,0,6],
[2,4,11],
[8,13,16],
[4,7,2],
[16,8,10],
[8,7,1],
[5,3,4],
[2,13,12],
[7,3,14]
]
const matching0 = sra.computeMatches(completePrefs)
console.log('Matching list for complete preferences')
console.log(matching0)
utils.seed(42)
let configurationFound = false
while (!configurationFound) {
const match = sra.computeMatches(utils.fillWithRandom(partialPrefs))
if (match !== null) {
configurationFound = true
console.log('\nMatching for partial preferences:')
console.log(match)
}
}