@scurrlin/stencil 1.18.1 → 1.18.3

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 +25 -31
  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 142 "Linked List Cycle II":
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 144 "Binary Tree Preorder Traversal":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,42 +24,36 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def detectCycle(self, head: Optional[ListNode]) -> Optional[ListNode]:
28
- slow = fast = head
29
-
30
- while fast and fast.next:
31
- slow = slow.next
32
- fast = fast.next.next
33
- if slow == fast:
34
- break
35
- else: return None
36
-
37
- fast = head
38
- while fast != slow:
39
- fast = fast.next
40
- slow = slow.next
41
- return slow
27
+ def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
28
+ curr, stack = root, []
29
+ res = []
30
+
31
+ while curr or stack:
32
+ if curr:
33
+ res.append(curr.val)
34
+ stack.append(curr.right)
35
+ curr = curr.left
36
+ else:
37
+ curr = stack.pop()
38
+ return res
42
39
  ```
43
40
 
44
41
  Solution with Stencil
45
42
 
46
43
  ```python
47
44
  c S:
48
- d d(s, h: O[L]) -> O[L]:
49
- s = f = h
50
-
51
- w f a f.n:
52
- s = s.n
53
- f = f.n.n
54
- i s == f:
55
- b
56
- e: r N
57
-
58
- f = h
59
- w f != s:
60
- f = f.n
61
- s = s.n
62
- r s
45
+ d p(s, r: O[T]) -> L[i]:
46
+ c, s = r, []
47
+ r = []
48
+
49
+ w c o s:
50
+ i c:
51
+ r.a(c.v)
52
+ s.a(c.r)
53
+ c = c.l
54
+ e:
55
+ c = s.p()
56
+ r r
63
57
  ```
64
58
 
65
59
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.18.1",
3
+ "version": "1.18.3",
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": {