leet-tui 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -79
- package/package.json +2 -1
- package/scripts/test_languages.sh +813 -0
- package/scripts/test_solutions/001_two_sum.c +15 -0
- package/scripts/test_solutions/001_two_sum.cpp +14 -0
- package/scripts/test_solutions/001_two_sum.js +11 -0
- package/scripts/test_solutions/001_two_sum.py +8 -0
- package/scripts/test_solutions/007_reverse_integer.c +9 -0
- package/scripts/test_solutions/007_reverse_integer.cpp +12 -0
- package/scripts/test_solutions/007_reverse_integer.js +12 -0
- package/scripts/test_solutions/007_reverse_integer.py +11 -0
- package/scripts/test_solutions/049_group_anagrams.c +14 -0
- package/scripts/test_solutions/049_group_anagrams.cpp +16 -0
- package/scripts/test_solutions/049_group_anagrams.js +9 -0
- package/scripts/test_solutions/049_group_anagrams.py +8 -0
- package/scripts/test_solutions/190_reverse_bits.c +8 -0
- package/scripts/test_solutions/190_reverse_bits.cpp +11 -0
- package/scripts/test_solutions/190_reverse_bits.js +8 -0
- package/scripts/test_solutions/190_reverse_bits.py +6 -0
- package/scripts/test_solutions/217_contains_duplicate.c +17 -0
- package/scripts/test_solutions/217_contains_duplicate.cpp +11 -0
- package/scripts/test_solutions/217_contains_duplicate.js +8 -0
- package/scripts/test_solutions/217_contains_duplicate.py +2 -0
- package/scripts/test_solutions/242_valid_anagram.c +14 -0
- package/scripts/test_solutions/242_valid_anagram.cpp +15 -0
- package/scripts/test_solutions/242_valid_anagram.js +10 -0
- package/scripts/test_solutions/242_valid_anagram.py +11 -0
- package/scripts/test_solutions/268_missing_number.c +7 -0
- package/scripts/test_solutions/268_missing_number.cpp +10 -0
- package/scripts/test_solutions/268_missing_number.js +8 -0
- package/scripts/test_solutions/268_missing_number.py +6 -0
- package/scripts/test_solutions/338_counting_bits.c +8 -0
- package/scripts/test_solutions/338_counting_bits.cpp +10 -0
- package/scripts/test_solutions/338_counting_bits.js +7 -0
- package/scripts/test_solutions/338_counting_bits.py +5 -0
- package/scripts/test_solutions/347_top_k_frequent.c +29 -0
- package/scripts/test_solutions/347_top_k_frequent.cpp +19 -0
- package/scripts/test_solutions/347_top_k_frequent.js +11 -0
- package/scripts/test_solutions/347_top_k_frequent.py +13 -0
- package/scripts/test_solutions/371_sum_of_two_integers.c +8 -0
- package/scripts/test_solutions/371_sum_of_two_integers.cpp +11 -0
- package/scripts/test_solutions/371_sum_of_two_integers.js +8 -0
- package/scripts/test_solutions/371_sum_of_two_integers.py +8 -0
package/README.md
CHANGED
|
@@ -4,27 +4,65 @@ A terminal user interface (TUI) application for solving LeetCode problems with a
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
7
|
+
- **149 NeetCode problems**: Curated problems from the NeetCode 150 list with full test suites
|
|
8
|
+
- **Multi-language support**: JavaScript, Python, C, and C++
|
|
9
|
+
- **Two test modes**:
|
|
10
|
+
- **Run (Ctrl+R)**: Quick validation with 3-5 test cases
|
|
11
|
+
- **Submit (Ctrl+S)**: Full validation with 50-200 test cases
|
|
12
|
+
- **Complexity analysis**: Automatic time/space complexity estimation after passing tests
|
|
8
13
|
- **Split-screen interface**: 1/3 for problem description, 2/3 for Neovim editor
|
|
9
|
-
- **Automatic boilerplate generation**: Each problem gets custom boilerplate code and test cases
|
|
10
|
-
- **Run tests locally**: Press Ctrl+R to run your solution against test cases with instant feedback
|
|
11
|
-
- **Color-coded results**: Test output shows PASSED in green, FAILED in red
|
|
12
14
|
- **Embedded Neovim**: Full Neovim functionality within the TUI
|
|
13
|
-
- **
|
|
15
|
+
- **Scrollable results modal**: Navigate through test output with keyboard
|
|
16
|
+
- **Color-coded results**: PASSED in green, FAILED in red
|
|
14
17
|
- **Organized solution files**: Solutions saved to `~/.local/share/leet-tui/solutions/`
|
|
15
|
-
- **Proper window sizing**: Neovim automatically fits the available space
|
|
16
|
-
- **Focus switching**: Toggle between question pane and editor pane
|
|
17
|
-
- **Scrollable question view**: Navigate through problem descriptions
|
|
18
|
-
- **Proper input forwarding**: All keyboard shortcuts work in Neovim (arrows, Ctrl combinations, etc.)
|
|
19
18
|
|
|
20
|
-
##
|
|
19
|
+
## Test Output
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
### Run Mode (Ctrl+R)
|
|
22
|
+
Verbose output showing each test case with input/output:
|
|
23
|
+
```
|
|
24
|
+
Test 1: PASSED [0.05 ms]
|
|
25
|
+
Input: [2,7,11,15], 9
|
|
26
|
+
Output: [0,1]
|
|
27
|
+
|
|
28
|
+
Test 2: PASSED [0.03 ms]
|
|
29
|
+
Input: [3,2,4], 6
|
|
30
|
+
Output: [1,2]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Submit Mode (Ctrl+S)
|
|
34
|
+
Compact table format for large test suites:
|
|
35
|
+
```
|
|
36
|
+
+-------+--------+--------------+
|
|
37
|
+
| Test | Status | Time |
|
|
38
|
+
+-------+--------+--------------+
|
|
39
|
+
| 1 | ✓ | 0.05 ms |
|
|
40
|
+
| 2 | ✓ | 0.03 ms |
|
|
41
|
+
| 3 | ✗ | 0.02 ms |
|
|
42
|
+
+-------+--------+--------------+
|
|
43
|
+
|
|
44
|
+
Results: 2 passed, 1 failed of 3 tests
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Complexity Analysis
|
|
48
|
+
After all tests pass, benchmarks run with statistical analysis:
|
|
49
|
+
```
|
|
50
|
+
Warming up JIT compiler...
|
|
51
|
+
Running benchmarks (5 rounds each, taking median)...
|
|
52
|
+
|
|
53
|
+
+-------------+------------------+------------+--------------+
|
|
54
|
+
| n | Median Time | Runs | Std Dev |
|
|
55
|
+
+-------------+------------------+------------+--------------+
|
|
56
|
+
| 10000 | 0.15 ms | 6640 | 1.2% |
|
|
57
|
+
| 100000 | 1.52 ms | 660 | 0.8% |
|
|
58
|
+
| 1000000 | 15.21 ms | 66 | 2.1% |
|
|
59
|
+
+-------------+------------------+------------+--------------+
|
|
60
|
+
|
|
61
|
+
Time Complexity: O(n) (slope: 1.00)
|
|
62
|
+
Space Complexity: O(n) estimated
|
|
63
|
+
|
|
64
|
+
Note: Std Dev < 5% indicates stable results
|
|
65
|
+
```
|
|
28
66
|
|
|
29
67
|
## Installation
|
|
30
68
|
|
|
@@ -34,115 +72,168 @@ The application uses:
|
|
|
34
72
|
npm install -g leet-tui
|
|
35
73
|
```
|
|
36
74
|
|
|
37
|
-
This
|
|
75
|
+
This installs `leet-tui` globally and adds it to your PATH. Run from anywhere:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
leet-tui
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Via Cargo
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cargo install leet-tui
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This installs the binary to `~/.cargo/bin/` (make sure it's in your PATH).
|
|
38
88
|
|
|
39
89
|
### From source
|
|
40
90
|
|
|
41
91
|
Prerequisites:
|
|
42
92
|
- Rust (1.70+)
|
|
43
93
|
- Neovim installed and available in PATH
|
|
94
|
+
- For JavaScript: Bun or Node.js
|
|
95
|
+
- For Python: Python 3.x
|
|
96
|
+
- For C/C++: GCC or Clang
|
|
44
97
|
|
|
45
98
|
```bash
|
|
99
|
+
git clone https://github.com/trevor-ofarrell/leet-tui
|
|
100
|
+
cd leet-tui
|
|
46
101
|
cargo build --release
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Then either run directly:
|
|
105
|
+
```bash
|
|
47
106
|
./target/release/leet-tui
|
|
48
107
|
```
|
|
49
108
|
|
|
50
|
-
|
|
109
|
+
Or install globally:
|
|
110
|
+
```bash
|
|
111
|
+
cargo install --path .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
Once installed globally, run from any directory:
|
|
51
117
|
|
|
52
118
|
```bash
|
|
53
119
|
leet-tui
|
|
54
120
|
```
|
|
55
121
|
|
|
122
|
+
Solutions are saved to `~/.local/share/leet-tui/solutions/` organized by language.
|
|
123
|
+
|
|
56
124
|
## Keyboard Shortcuts
|
|
57
125
|
|
|
58
|
-
###
|
|
59
|
-
- **Up/Down**: Navigate problem list
|
|
60
|
-
- **Enter**: Select a problem
|
|
126
|
+
### Global
|
|
61
127
|
- **Ctrl+C**: Quit application
|
|
62
128
|
|
|
63
|
-
###
|
|
64
|
-
- **Ctrl+R**: Save file and run tests (auto-saves before testing)
|
|
65
|
-
- **Ctrl+Q**: Switch focus between question pane and editor pane
|
|
66
|
-
- **Ctrl+H**: Back to home page
|
|
67
|
-
- **Ctrl+C**: Quit application
|
|
68
|
-
- **Esc**: Close test results popup
|
|
69
|
-
- **Up/Down**: Scroll question (when question pane is focused)
|
|
70
|
-
- **PageUp/PageDown**: Fast scroll question (when question pane is focused)
|
|
71
|
-
- **Home**: Jump to top of question (when question pane is focused)
|
|
72
|
-
- **All Neovim shortcuts**: Work when editor pane is focused
|
|
129
|
+
### Home Page
|
|
73
130
|
|
|
74
|
-
|
|
131
|
+
#### Problem List (default focus)
|
|
132
|
+
- **Up/Down**: Navigate problem list (circular)
|
|
133
|
+
- **Enter**: Open selected problem
|
|
134
|
+
- **L**: Cycle language (JS → Python → C → C++)
|
|
135
|
+
- **/**: Jump to search box
|
|
75
136
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
├── pty.rs # PTY manager for Neovim integration
|
|
80
|
-
├── input.rs # Keyboard input handling and ANSI escape sequence mapping
|
|
81
|
-
└── leetcode.rs # LeetCode API integration (currently with sample data)
|
|
82
|
-
```
|
|
137
|
+
#### Navigation
|
|
138
|
+
- **Tab**: Cycle focus forward (List → Search → List Filter → Category → Difficulty → Progress)
|
|
139
|
+
- **Shift+Tab**: Cycle focus backward
|
|
83
140
|
|
|
84
|
-
|
|
141
|
+
#### Search Box
|
|
142
|
+
- **Type**: Filter problems by title or number
|
|
143
|
+
- **Enter**: Return to problem list
|
|
144
|
+
- **Esc**: Clear search and return to problem list
|
|
85
145
|
|
|
86
|
-
|
|
146
|
+
#### Filters (List, Category, Difficulty, Progress)
|
|
147
|
+
- **Left/Right**: Cycle through filter options (circular)
|
|
148
|
+
- **Enter**: Return to problem list
|
|
87
149
|
|
|
88
|
-
|
|
150
|
+
### Question View
|
|
89
151
|
|
|
90
|
-
|
|
152
|
+
#### Editor Pane (default focus)
|
|
153
|
+
- **All Neovim shortcuts**: Full Neovim functionality
|
|
154
|
+
- **Ctrl+R**: Run tests (quick mode, 3-5 cases)
|
|
155
|
+
- **Ctrl+S**: Submit tests (full mode, 50-200 cases)
|
|
156
|
+
- **Ctrl+Q**: Switch focus to question pane
|
|
157
|
+
- **Ctrl+T**: Toggle tips visibility
|
|
158
|
+
- **Ctrl+H**: Back to home page
|
|
91
159
|
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
160
|
+
#### Question Pane
|
|
161
|
+
- **Up/Down**: Scroll question text
|
|
162
|
+
- **PageUp/PageDown**: Fast scroll (10 lines)
|
|
163
|
+
- **Home**: Jump to top
|
|
164
|
+
- **Shift+R**: Reset solution to template
|
|
165
|
+
- **Ctrl+Q**: Switch focus to editor pane
|
|
97
166
|
|
|
98
|
-
###
|
|
167
|
+
### Results Modal
|
|
168
|
+
- **Esc**: Close modal
|
|
169
|
+
- **Up/Down or j/k**: Scroll results
|
|
170
|
+
- **PageUp/PageDown**: Fast scroll (10 lines)
|
|
171
|
+
- **Home/End or g/G**: Jump to top/bottom
|
|
99
172
|
|
|
100
|
-
|
|
101
|
-
- **Question pane**: Arrow keys scroll the problem description
|
|
102
|
-
- **Editor pane**: All input is forwarded to Neovim
|
|
173
|
+
## Architecture
|
|
103
174
|
|
|
104
|
-
|
|
175
|
+
The application uses:
|
|
176
|
+
- **ratatui**: Terminal UI framework
|
|
177
|
+
- **portable-pty**: PTY system for spawning Neovim
|
|
178
|
+
- **vt100**: Terminal emulator parser
|
|
179
|
+
- **tui-term**: Widget for rendering terminal output
|
|
180
|
+
- **crossterm**: Cross-platform terminal manipulation
|
|
181
|
+
- **rust-embed**: Embedded problem data and test cases
|
|
105
182
|
|
|
106
|
-
|
|
183
|
+
## Project Structure
|
|
107
184
|
|
|
108
|
-
|
|
185
|
+
```
|
|
186
|
+
src/
|
|
187
|
+
├── main.rs # Main application logic and UI rendering
|
|
188
|
+
├── pty.rs # PTY manager for Neovim integration
|
|
189
|
+
├── input.rs # Keyboard input handling
|
|
190
|
+
├── leetcode.rs # Problem data and test runner generation
|
|
191
|
+
└── language.rs # Multi-language support
|
|
109
192
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
193
|
+
problems/ # Embedded problem definitions (JSON)
|
|
194
|
+
testcases/ # Extended test cases for run/submit modes
|
|
195
|
+
```
|
|
113
196
|
|
|
114
|
-
|
|
197
|
+
## Benchmarking Methodology
|
|
115
198
|
|
|
116
|
-
|
|
117
|
-
- Setting environment variables (e.g., `NVIM_APPNAME` for different configs)
|
|
118
|
-
- Passing command-line arguments in `src/pty.rs:25`
|
|
119
|
-
- Creating a custom init file for the TUI context
|
|
199
|
+
The complexity analysis uses robust benchmarking practices:
|
|
120
200
|
|
|
121
|
-
|
|
201
|
+
1. **Aggressive warmup**: 500 iterations across multiple input sizes to stabilize JIT
|
|
202
|
+
2. **Multiple rounds**: 5 benchmark rounds per size
|
|
203
|
+
3. **Median selection**: Uses median instead of mean to filter outliers
|
|
204
|
+
4. **Statistical reporting**: Shows relative standard deviation for confidence
|
|
205
|
+
5. **GC management**: Forces garbage collection between rounds
|
|
206
|
+
|
|
207
|
+
This produces repeatable results - look for Std Dev < 5% to confirm stability.
|
|
208
|
+
|
|
209
|
+
## Supported Languages
|
|
210
|
+
|
|
211
|
+
| Language | Runtime | File Extension |
|
|
212
|
+
|----------|---------|----------------|
|
|
213
|
+
| JavaScript | Bun (preferred) or Node.js | `.js` |
|
|
214
|
+
| Python | Python 3.x | `.py` |
|
|
215
|
+
| C | GCC/Clang | `.c` |
|
|
216
|
+
| C++ | G++/Clang++ | `.cpp` |
|
|
122
217
|
|
|
123
218
|
## Troubleshooting
|
|
124
219
|
|
|
125
220
|
### Keys not working in Neovim
|
|
126
|
-
|
|
127
221
|
If certain key combinations don't work, you may need to add them to the `key_to_bytes` function in `src/input.rs`.
|
|
128
222
|
|
|
129
223
|
### Terminal size issues
|
|
130
|
-
|
|
131
224
|
The application handles resize events and updates the PTY size accordingly. If you experience rendering issues, try resizing your terminal.
|
|
132
225
|
|
|
133
|
-
###
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
- [ ] Custom Neovim configuration per problem type
|
|
145
|
-
- [ ] Split terminal for running tests
|
|
226
|
+
### Inconsistent benchmark results
|
|
227
|
+
If Std Dev is high (>10%), try:
|
|
228
|
+
- Closing other applications
|
|
229
|
+
- Running on a less loaded system
|
|
230
|
+
- The median should still be reasonably stable
|
|
231
|
+
|
|
232
|
+
### Test runner errors
|
|
233
|
+
Ensure the appropriate runtime is installed:
|
|
234
|
+
- JavaScript: `bun --version` or `node --version`
|
|
235
|
+
- Python: `python3 --version`
|
|
236
|
+
- C/C++: `gcc --version` or `clang --version`
|
|
146
237
|
|
|
147
238
|
## License
|
|
148
239
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leet-tui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A terminal UI for practicing LeetCode Blind 75 problems with embedded Neovim",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": "Trevor O'Farrell",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "https://github.com/trevor-ofarrell/leet-tui"
|