@scurrlin/stencil 1.5.5 → 1.5.7
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 +17 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
[](https://www.npmjs.com/package/@scurrlin/stencil)
|
|
12
|
+
|
|
11
13
|
## Overview
|
|
12
14
|
|
|
13
15
|
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.
|
|
14
16
|
|
|
15
17
|
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.
|
|
16
18
|
|
|
17
|
-
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
|
|
19
|
+
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 1 "Two Sum":
|
|
18
20
|
|
|
19
21
|
## Example
|
|
20
22
|
|
|
@@ -22,40 +24,26 @@ Solution
|
|
|
22
24
|
|
|
23
25
|
```python
|
|
24
26
|
class Solution:
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else:
|
|
33
|
-
stack.pop()
|
|
34
|
-
if not stack:
|
|
35
|
-
stack.append(i)
|
|
36
|
-
else:
|
|
37
|
-
max_len = max(max_len, i - stack[-1])
|
|
38
|
-
return max_len
|
|
27
|
+
def twoSum(self, nums: List[int], target: int) -> List[int]:
|
|
28
|
+
hash_map = {}
|
|
29
|
+
for i, num in enumerate(nums):
|
|
30
|
+
x = target - num
|
|
31
|
+
if x in hash_map:
|
|
32
|
+
return [hash_map[x], i]
|
|
33
|
+
hash_map[num] = i
|
|
39
34
|
```
|
|
40
35
|
|
|
41
36
|
Solution with Stencil
|
|
42
37
|
|
|
43
38
|
```python
|
|
44
39
|
c S:
|
|
45
|
-
d
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
e:
|
|
53
|
-
s.p()
|
|
54
|
-
i n s:
|
|
55
|
-
s.a(i)
|
|
56
|
-
e:
|
|
57
|
-
m_l = m(m_l, i - s[-1])
|
|
58
|
-
r m_l
|
|
40
|
+
d t(s, n: L[i], t: i) -> L[i]:
|
|
41
|
+
h_m = {}
|
|
42
|
+
f i, n i e(n):
|
|
43
|
+
x = t - n
|
|
44
|
+
i x i h_m:
|
|
45
|
+
r [h_m[x], i]
|
|
46
|
+
h_m[n] = i
|
|
59
47
|
```
|
|
60
48
|
|
|
61
49
|
## Local Installation
|