@scurrlin/stencil
Version:
A memorization tool that strips code down to first letters and punctuation only.
85 lines (63 loc) • 3.26 kB
Markdown
```
███████ ████████ ███████ ███ ██ ██████ ██ ██
██ ██ ██ ████ ██ ██ ██ ██
███████ ██ █████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ███████ ██ ████ ██████ ██ ███████
```
[](https://www.npmjs.com/package/@scurrlin/stencil)
## Overview
Whether you are studying for technical interviews, or just starting your coding journey, pattern recognition and memorization are absolutely necessary. It doesn't take a valedictorian to figure that out, but how exactly are you supposed to do that? Between data structures, algorithms, and design patterns, the task of incrementally committing enough of that information to memory can feel impossible. You could spend hours studying fully implemented algorithms only to draw a blank when staring at an empty code editor.
Most people when they attempt to memorize something study the full text and then attempt to regurgitate it on a blank page. Shocking, I know... but what if there was a step in between? What if memorization and pattern recognition weren't all or nothing games? This is where Stencil comes in.
Stencil is a language-agnostic memorization tool that strips code files down to their first letters while preserving spacing, capitalization, and punctuation. The "stencil" of the file is designed to act as a bridge between having something partially memorized and fully memorized. Below is an example of Stencil in action using LeetCode problem 275 "H-Index II":
## Example
Solution
```python
class Solution:
def hIndex(self, citations: List[int]) -> int:
n = len(citations)
left, right = 0, n - 1
while left <= right:
mid = (left + right) // 2
if citations[mid] == n - mid:
return n - mid
elif citations[mid] < n - mid:
left = mid + 1
else:
right = mid - 1
return n - left
```
Solution with Stencil
```python
c S:
d h(s, c: L[i]) -> i:
n = l(c)
l, r = 0, n - 1
w l <= r:
m = (l + r) // 2
i c[m] == n - m:
r n - m
e c[m] < n - m:
l = m + 1
e:
r = m - 1
r n - l
```
## Local Installation
To install **Stencil** locally, run the following command in the terminal of your directory:
```bash
npm install @scurrlin/stencil
```
Once installed, you can run it with the following command:
```bash
npx stencil path/to/your/file.py --start <start_line> --end <end_line>
```
## Global Installation
If you prefer to install **Stencil** globally, run the following command in your terminal:
```bash
npm install -g @scurrlin/stencil
```
Once installed, you can run it with the following command:
```bash
stencil path/to/your/file.py --start <start_line> --end <end_line>
```