In order to easily reference which programming problems cover which topics I wrote this. It can easily be used for anything else by changing the filter tags. You can also get rid of the following :
let include = new Set([
"BFS","DFS","Recursion","Tree","Trie","Graph","Heap","Array","HashMap",
"Set","LinkedList","GhostNodes","Sorting","SlidingWindow","Backtracking",
"TopologicalSort","DP","TreeTraversal","BinarySearch"
].map((x) => `#${x}`));
tagMap.forEach((v, k) => {
if (!include.has(k))
tagMap.delete(k);
});
If you want it to make tables for any tag.
Heres the snippet:
` ``dataviewjs
var _a;
let filtertags = ["programming", "problem"];
let include = new Set([
"BFS","DFS","Recursion","Tree","Trie","Graph","Heap","Array","HashMap",
"Set","LinkedList","GhostNodes","Sorting","SlidingWindow","Backtracking",
"TopologicalSort","DP","TreeTraversal","BinarySearch"
].map((x) => `#${x}`));
let source = filtertags.map((tag) => `#${tag}`).join(" AND ");
let files = dv.pages(`${source} AND -"00 Meta/06 Templates"`).map((p) => p.file);
let tagMap = new Map();
for (let page of files)
for (let tag of page.tags) {
let data = (_a = tagMap.get(tag)) != null ? _a : { tagnum: 0, pages: [] };
data.tagnum++;
data.pages.push(page);
tagMap.set(tag, data);
}
filtertags.forEach((t) => tagMap.delete(`#${t}`));
tagMap.forEach((v, k) => {
if (!include.has(k))
tagMap.delete(k);
});
let count = 1;
let headers = [];
let elements = [];
let sorted = Array.from(tagMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
for (let [tag, data] of sorted) {
headers.push(`${tag.replace("#", "")} (${data.tagnum})`);
elements.push(data.pages.map((p) => p.link));
if (count++ % 3 == 0) {
dv.table(headers, [elements]);
headers = [], elements = [];
}
}
if (headers.length > 0)
dv.table(headers, [elements]);
` ``