-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskyeFilter.js
More file actions
47 lines (44 loc) · 1.21 KB
/
Copy pathskyeFilter.js
File metadata and controls
47 lines (44 loc) · 1.21 KB
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
//path :: [{Section}]
//curr :: {Section}
//iteration :: Int --starts at 0
//classList :: [{[{Section}]}]
//foundpaths :: [[{Section}]]
function findSchedules(path, curr, iteration, classList, foundpaths) {
if (isEmptyObject(curr.schedules)) return 0;
//If you reach the end, you won!
if(iteration === classList.length - 1) {
var newpath = path.slice();
newpath.push(curr);
foundpaths.push(newpath);
return 1;
}
//Otherwise you do work
else {
var combos = 0;
for (var s of classList[iteration + 1].sections) {
if (!isEmptyObject(curr.schedules) &&
!conflict(curr, s) &&
path.every(function(element) {
return (!conflict(element, s));
})) {
var newpath = path.slice();
newpath.push(curr);
combos += findSchedules(newpath, s, iteration + 1, classList, foundpaths);
}
}
return combos;
}
}
function isEmptyObject(obj) {
for (var name in obj) {
return false;
}
return true;
}
function fullOnFilter (listOfFullClasses) {
for (classes in listOfFullClasses) {
for (curr in clasess.schedules) {
findSchedules([], curr, 0, listOfFullClasses, [])
}
}
}