-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_2.js
84 lines (74 loc) · 2.88 KB
/
math_2.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
82
83
84
import xlsx from "xlsx";
import * as fs from "fs";
const other = JSON.parse(fs.readFileSync('static/other.json').toString());
const times = [
[{date: 0, sh: 9, sm: 0, eh: 10, em: 30}, {date: 2, sh: 9, sm: 0, eh: 10, em: 30}],
[{date: 0, sh: 10, sm: 30, eh: 12, em: 0}, {date: 2, sh: 10, sm: 30, eh: 12, em: 0}],
[{date: 0, sh: 13, sm: 0, eh: 14, em: 30}, {date: 2, sh: 13, sm: 0, eh: 14, em: 30}],
[{date: 0, sh: 14, sm: 30, eh: 16, em: 0}, {date: 2, sh: 14, sm: 30, eh: 16, em: 0}],
[{date: 0, sh: 16, sm: 0, eh: 17, em: 30}, {date: 2, sh: 16, sm: 0, eh: 17, em: 30}],
[{date: 1, sh: 9, sm: 0, eh: 10, em: 30}, {date: 3, sh: 9, sm: 0, eh: 10, em: 30}],
[{date: 1, sh: 10, sm: 30, eh: 12, em: 0}, {date: 3, sh: 10, sm: 30, eh: 12, em: 0}],
[{date: 1, sh: 13, sm: 0, eh: 14, em: 30}, {date: 3, sh: 13, sm: 0, eh: 14, em: 30}],
[{date: 1, sh: 14, sm: 30, eh: 16, em: 0}, {date: 3, sh: 14, sm: 30, eh: 16, em: 0}],
[{date: 1, sh: 16, sm: 0, eh: 17, em: 30}, {date: 3, sh: 16, sm: 0, eh: 17, em: 30}],
]
const addTimes = [
[{date: 4, sh: 10, sm: 0, eh: 11, em: 0}],
[{date: 4, sh: 11, sm: 0, eh: 12, em: 0}],
[{date: 4, sh: 13, sm: 0, eh: 14, em: 0}],
[{date: 4, sh: 14, sm: 0, eh: 15, em: 0}],
]
const add = fs.readFileSync('add.txt').toString().split('\n').map(i => i.trim());
const addRes = {};
let addC = 0;
for(const i of add) {
if (i === '') {
addC++;
} else {
const code = 'MAS' + i.slice(0, 3);
const divs = i.slice(3).split('');
for(const group of divs)
addRes[code + group] = addTimes[addC];
}
}
const nm = fs.readFileSync('t.txt').toString().split('\n').map(i => i.trim());
const res = [];
let curr = [];
for(const i of nm) {
if (i === '') {
res.push(curr);
curr = [];
} else {
curr.push(i);
}
}
res.push(curr);
const dump = []
for(let i=0;i<res.length;i++) {
for(const l of res[i]) {
const r = l.split(',');
const dept = 151;
const type = '';
const code = 'MAS' + r[0].slice(0, 3);
const divs = r[0].slice(3).split('');
const title = r[3] || other[code]?.[0] || '';
const prof = [r[1]];
const where = r[2];
const time = times[i];
const exam = [];
const credit = 3;
const kcode = '';
if(!divs.length)
dump.push({dept, type, code, title, group: '', prof, where, time, exam, credit, kcode})
for(const group of divs)
{
dump.push({dept, type, code, title, group, prof, where, time: [...time, ...(
addRes[code + group] || []
)], exam, credit, kcode})
}
}
}
fs.writeFileSync('add_2025_1.json', JSON.stringify(dump, null, 4));
fs.writeFileSync('static/add_2025_1.json', JSON.stringify(dump, null, 4));
//return {dept, type, code, title, group, prof, where, time, exam, credit, kcode};