@scurrlin/stencil 1.18.2 → 1.18.4

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 +29 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ Whether you are studying for technical interviews, or just starting your coding
16
16
 
17
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.
18
18
 
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 143 "Reorder List":
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 145 "Binary Tree Postorder Traversal":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,54 +24,40 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def reorderList(self, head: Optional[ListNode]) -> None:
28
- if not head or not head.next:
29
- return
30
- slow, fast = head, head.next
31
-
32
- while fast and fast.next:
33
- slow = slow.next
34
- fast = fast.next.next
35
- second = slow.next
36
- prev = slow.next = None
37
- while second:
38
- temp = second.next
39
- second.next = prev
40
- prev = second
41
- second = temp
42
- first, second = head, prev
43
- while second:
44
- temp1, temp2 = first.next, second.next
45
- first.next = second
46
- second.next = temp1
47
- first, second = temp1, temp2
27
+ def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
28
+ if root is None:
29
+ return []
30
+
31
+ stack, result = [root], []
32
+ while stack:
33
+ node = stack.pop()
34
+ result.append(node.val)
35
+ if node.left:
36
+ stack.append(node.left)
37
+ if node.right:
38
+ stack.append(node.right)
39
+ result.reverse()
40
+ return result
48
41
  ```
49
42
 
50
43
  Solution with Stencil
51
44
 
52
45
  ```python
53
46
  c S:
54
- d r(s, h: O[L]) -> N:
55
- i n h o n h.n:
56
- r
57
- s, f = h, h.n
58
-
59
- w f a f.n:
60
- s = s.n
61
- f = f.n.n
62
- s = s.n
63
- p = s.n = N
64
- w s:
65
- t = s.n
66
- s.n = p
67
- p = s
68
- s = t
69
- f, s = h, p
70
- w s:
71
- t, t = f.n, s.n
72
- f.n = s
73
- s.n = t
74
- f, s = t, t
47
+ d p(s, r: O[T]) -> L[i]:
48
+ i r i N:
49
+ r []
50
+
51
+ s, r = [r], []
52
+ w s:
53
+ n = s.p()
54
+ r.a(n.v)
55
+ i n.l:
56
+ s.a(n.l)
57
+ i n.r:
58
+ s.a(n.r)
59
+ r.r()
60
+ r r
75
61
  ```
76
62
 
77
63
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.18.2",
3
+ "version": "1.18.4",
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": {