-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
verifySiteData.js
96 lines (89 loc) · 2.1 KB
/
verifySiteData.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
85
86
87
88
89
90
91
92
93
94
95
96
/** Script to verify code links in ./.problemSiteData.json */
const fs = require('fs');
const https = require('/opt/homebrew/lib/node_modules/sync-request');
const PROBLEMS_SITE_DATA = JSON.parse(fs.readFileSync('./.problemSiteData.json', 'utf8'));
const languageMap = {
c: {
name: 'C',
directory: 'c',
extension: 'c'
},
cpp: {
name: 'C++',
directory: 'cpp',
extension: 'cpp'
},
csharp: {
name: 'C#',
directory: 'csharp',
extension: 'cs'
},
java: {
name: 'Java',
directory: 'java',
extension: 'java'
},
python: {
name: 'Python',
directory: 'python',
extension: 'py'
},
javascript: {
name: 'JavaScript',
directory: 'javascript',
extension: 'js'
},
typescript: {
name: 'TypeScript',
directory: 'typescript',
extension: 'ts'
},
go: {
name: 'Go',
directory: 'go',
extension: 'go'
},
ruby: {
name: 'Ruby',
directory: 'ruby',
extension: 'rb'
},
swift: {
name: 'Swift',
directory: 'swift',
extension: 'swift'
},
kotlin: {
name: 'Kotlin',
directory: 'kotlin',
extension: 'kt'
},
rust: {
name: 'Rust',
directory: 'rust',
extension: 'rs'
},
scala: {
name: 'Scala',
directory: 'scala',
extension: 'scala'
},
dart: {
name: 'Dart',
directory: 'dart',
extension: 'dart'
},
};
const GITHUB_BASE_URL = 'https://github.com/neetcode-gh/leetcode/blob/main';
for (const problem of PROBLEMS_SITE_DATA) {
for (const language in languageMap) {
if (problem[language] !== true) continue;
const { directory, extension } = languageMap[language];
const codeUrl = `${GITHUB_BASE_URL}/${directory}/${problem.code}.${extension}`;
const res = https('GET', codeUrl).statusCode;
if (res !== 200) {
console.log(codeUrl)
console.log(res)
}
}
}