2026-06-01 02:33:30 +08:00
|
|
|
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
|
|
|
import { join, dirname } from "node:path";
|
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
|
2026-06-01 16:12:21 +08:00
|
|
|
const roadmap = readFileSync(join(__dirname, "../org/study_deck_02/roadmap.org"), "utf8");
|
|
|
|
|
const dsaDir = join(__dirname, "../org/study_deck_02/dsa");
|
2026-06-01 02:33:30 +08:00
|
|
|
|
|
|
|
|
const topicSlug = (name) =>
|
|
|
|
|
name
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/[^a-z0-9]+/g, "-")
|
|
|
|
|
.replace(/(^-|-$)/g, "");
|
|
|
|
|
|
|
|
|
|
let currentTopic = "";
|
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
|
|
for (const line of roadmap.split("\n")) {
|
|
|
|
|
const topicMatch = line.match(/^\* TODO (.+?) \[/);
|
|
|
|
|
if (topicMatch) {
|
|
|
|
|
currentTopic = topicSlug(topicMatch[1]);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const problemMatch = line.match(
|
2026-06-01 16:12:21 +08:00
|
|
|
/^\*\* TODO (\d+)\. (.+?) :(easy|medium|hard):/
|
2026-06-01 02:33:30 +08:00
|
|
|
);
|
|
|
|
|
if (problemMatch) {
|
|
|
|
|
const [, num, name, diff] = problemMatch;
|
|
|
|
|
const slug = name
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/[^a-z0-9]+/g, "-")
|
|
|
|
|
.replace(/(^-|-$)/g, "");
|
|
|
|
|
const code = `${num}-${slug}`;
|
|
|
|
|
const filePath = join(dsaDir, currentTopic, `${code}.org`);
|
|
|
|
|
|
|
|
|
|
if (existsSync(filePath)) continue;
|
|
|
|
|
|
2026-06-01 16:12:21 +08:00
|
|
|
const relPath = `../../roadmap.org::*${num}. ${name}`;
|
2026-06-01 17:12:10 +08:00
|
|
|
const content = `#+PROPERTY: STUDY_DECK_02
|
|
|
|
|
* TODO ${num}. ${name} :${diff}:
|
2026-06-01 02:33:30 +08:00
|
|
|
:PROPERTIES:
|
2026-06-01 17:06:27 +08:00
|
|
|
:NEETCODE: [[file:${relPath}][Roadmap]]
|
2026-06-01 02:33:30 +08:00
|
|
|
:END:
|
|
|
|
|
|
2026-06-01 02:39:53 +08:00
|
|
|
** TODO Approach
|
|
|
|
|
Write your approach here.
|
|
|
|
|
|
|
|
|
|
** TODO Python
|
|
|
|
|
#+begin_src python
|
|
|
|
|
|
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
** TODO C++
|
2026-06-01 02:33:30 +08:00
|
|
|
#+begin_src cpp
|
|
|
|
|
|
|
|
|
|
#+end_src
|
|
|
|
|
`;
|
|
|
|
|
writeFileSync(filePath, content);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(`Created ${count} note files`);
|