@scurrlin/stencil 1.2.8 → 1.2.9

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.
Files changed (2) hide show
  1. package/README.md +39 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,38 +14,56 @@ Whether you are studying for technical interviews, or just starting your coding
14
14
 
15
15
  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
16
 
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 141 "Linked List Cycle":
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 155 "Min Stack":
18
18
 
19
19
  ## Example
20
20
 
21
21
  Solution
22
22
 
23
23
  ```python
24
- class Solution:
25
- def hasCycle(self, head: Optional[ListNode]) -> bool:
26
- slow, fast = head, head
27
-
28
- while fast and fast.next:
29
- slow = slow.next
30
- fast = fast.next.next
31
- if slow == fast:
32
- return True
33
- return False
24
+ class MinStack:
25
+ def __init__(self):
26
+ self.stack = []
27
+ self.minStack = []
28
+
29
+ def push(self, val: int) -> None:
30
+ self.stack.append(val)
31
+ val = min(val, self.minStack[-1] if self.minStack else val)
32
+ self.minStack.append(val)
33
+
34
+ def pop(self) -> None:
35
+ self.stack.pop()
36
+ self.minStack.pop()
37
+
38
+ def top(self) -> int:
39
+ return self.stack[-1]
40
+
41
+ def getMin(self) -> int:
42
+ return self.minStack[-1]
34
43
  ```
35
44
 
36
45
  Solution with Stencil
37
46
 
38
47
  ```python
39
- c S:
40
- d h(s, h: O[L]) -> b:
41
- s, f = h, h
42
-
43
- w f a f.n:
44
- s = s.n
45
- f = f.n.n
46
- i s == f:
47
- r T
48
- r F
48
+ c M:
49
+ d __i__(s):
50
+ s.s = []
51
+ s.m = []
52
+
53
+ d p(s, v: i) -> N:
54
+ s.s.a(v)
55
+ v = m(v, s.m[-1] i s.m e v)
56
+ s.m.a(v)
57
+
58
+ d p(s) -> N:
59
+ s.s.p()
60
+ s.m.p()
61
+
62
+ d t(s) -> i:
63
+ r s.s[-1]
64
+
65
+ d g(s) -> i:
66
+ r s.m[-1]
49
67
  ```
50
68
 
51
69
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "A memorization tool that strips code down to first letters and punctuation only.",
5
5
  "main": "src/index.js",
6
6
  "bin": {