mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
- dot_omp: agent config/keybindings/mcp/themes/commands + loop defs, goals, run-loop.sh; dotstate config.yml symlink materialized; dbs, logs, sessions, memories, blobs, caches, .env (secret), and managed-skills excluded - .chezmoiexternal.toml: prdlk/nvim as git-repo external — no refreshPeriod + ff-only pull, local checkout wins over remote - yazi plugins: vendored source copies dropped (target-ignored already); package.toml is the manifest, installed via run_onchange ya pkg install hook; stale piper/easyjump pins bumped to match live content - herdr: plugins/github checkout, logs, session.json, .bak, release-notes dropped from sync (herdr-managed machine state)
75 lines
3.2 KiB
Markdown
75 lines
3.2 KiB
Markdown
---
|
||
description: Add super-simple line-by-line comments to a LeetCode solution file
|
||
---
|
||
|
||
Add beginner-level line-by-line comments to the LeetCode solution file at: $1
|
||
|
||
## Rules
|
||
|
||
1. **Read the file first.** It follows the standard on-disk format:
|
||
- A `/* ... */` header block containing problem number, title, difficulty, URL, description, examples, and constraints
|
||
- A JSDoc `@param`/`@return` block
|
||
- The solution function(s)
|
||
|
||
2. **Never touch the header block or JSDoc block.** Preserve them byte-for-byte.
|
||
|
||
3. **Never change the code.** Do not rename variables, reformat logic, alter whitespace inside expressions, or "improve" anything. Comments only. The file must produce an identical AST after your edit.
|
||
|
||
4. **Comment style — explain as if to a complete beginner who has never programmed:**
|
||
- One comment line (or short block) ABOVE each meaningful line/statement
|
||
- Use plain everyday language and physical metaphors:
|
||
- object/map → "box" ("Create an empty box to count how many times each number appears")
|
||
- increment → "add 1 to its count"
|
||
- `(freq[x] || 0) + 1` → "If we already saw this number, add 1 to its count. If we never saw it before, start counting from 1"
|
||
- sort comparator → spell out the rule in words ("put the letter that appears MORE times first; if tied, alphabetical order")
|
||
- return → say WHAT is being returned and WHY in plain words
|
||
- Explain the WHY, not just the WHAT ("so the next bigger numbers know there are more smaller ones")
|
||
- Inline comments (`// ...` at end of line) are fine for short trailing clarifications like `.join('')` → "glue the sorted letters back into a string"
|
||
- No jargon without immediate translation: if you must say "index", follow with "(its position)"
|
||
|
||
5. **Add a section banner** above the solution function in this exact style:
|
||
```js
|
||
// ============================================
|
||
// <problem number>. <problem title>
|
||
// ============================================
|
||
```
|
||
Pull the number and title from the header block.
|
||
|
||
6. **Multiple solutions in one file:** comment every one of them, each with its own banner (append "– Approach 2" etc. to the banner title).
|
||
|
||
7. **Extra instructions** (if provided after the file path): $@
|
||
|
||
8. **After editing**, print a one-line confirmation: file path + number of comment lines added. Nothing else.
|
||
|
||
## Example transformation
|
||
|
||
Input body:
|
||
```js
|
||
var smallerNumbersThanCurrent = function (nums) {
|
||
const freq = {};
|
||
for (let x of nums) freq[x] = (freq[x] || 0) + 1;
|
||
return nums.map((x) => smaller[x]);
|
||
};
|
||
```
|
||
|
||
Output body:
|
||
```js
|
||
// ============================================
|
||
// 1365. How Many Numbers Are Smaller Than the Current Number
|
||
// ============================================
|
||
|
||
var smallerNumbersThanCurrent = function (nums) {
|
||
// Create an empty box to store how many times each number appears
|
||
const freq = {};
|
||
|
||
// Go through every number in the list one by one
|
||
// If we already saw this number, add 1 to its count
|
||
// If we never saw it before, start counting from 1
|
||
for (let x of nums) freq[x] = (freq[x] || 0) + 1;
|
||
|
||
// Go through the original list and replace each number
|
||
// with "how many numbers are smaller than it"
|
||
return nums.map((x) => smaller[x]);
|
||
};
|
||
```
|