@scurrlin/stencil 1.4.6 → 1.4.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.
Files changed (2) hide show
  1. package/README.md +37 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ 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 21 "Merge Two Sorted Lists":
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 22 "Generate Parentheses":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,42 +22,48 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
26
- l1, l2 = list1, list2
27
- temp = ListNode(0)
28
- current = temp
29
-
30
- while l1 and l2:
31
- if l1.val <= l2.val:
32
- current.next = l1
33
- l1 = l1.next
34
- else:
35
- current.next = l2
36
- l2 = l2.next
37
- current = current.next
38
- current.next = l1 if l1 else l2
39
- return temp.next
25
+ def generateParenthesis(self, n: int) -> List[str]:
26
+ stack = []
27
+ res = []
28
+
29
+ def backtrack(openN, closedN):
30
+ if openN == closedN == n:
31
+ res.append("".join(stack))
32
+ return
33
+ if openN < n:
34
+ stack.append("(")
35
+ backtrack(openN + 1, closedN)
36
+ stack.pop()
37
+ if closedN < openN:
38
+ stack.append(")")
39
+ backtrack(openN, closedN + 1)
40
+ stack.pop()
41
+ backtrack(0, 0)
42
+ return res
40
43
  ```
41
44
 
42
45
  Solution with Stencil
43
46
 
44
47
  ```python
45
48
  c S:
46
- d m(s, l: O[L], l: O[L]) -> O[L]:
47
- l, l = l, l
48
- t = L(0)
49
- c = t
50
-
51
- w l a l:
52
- i l.v <= l.v:
53
- c.n = l
54
- l = l.n
55
- e:
56
- c.n = l
57
- l = l.n
58
- c = c.n
59
- c.n = l i l e l
60
- r t.n
49
+ d g(s, n: i) -> L[s]:
50
+ s = []
51
+ r = []
52
+
53
+ d b(o, c):
54
+ i o == c == n:
55
+ r.a("".j(s))
56
+ r
57
+ i o < n:
58
+ s.a("(")
59
+ b(o + 1, c)
60
+ s.p()
61
+ i c < o:
62
+ s.a(")")
63
+ b(o, c + 1)
64
+ s.p()
65
+ b(0, 0)
66
+ r r
61
67
  ```
62
68
 
63
69
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
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": {