@scurrlin/stencil 1.1.2 → 1.1.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 +29 -41
  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 143 "Reorder List":
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":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,54 +22,42 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def reorderList(self, head: ListNode) -> None:
26
- if not head or not head.next:
27
- return
28
- slow, fast = head, head.next
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
29
 
30
- while fast and fast.next:
31
- slow = slow.next
32
- fast = fast.next.next
33
- second = slow.next
34
- prev = slow.next = None
35
- while second:
36
- temp = second.next
37
- second.next = prev
38
- prev = second
39
- second = temp
40
- first, second = head, prev
41
- while second:
42
- temp1, temp2 = first.next, second.next
43
- first.next = second
44
- second.next = temp1
45
- first, second = temp1, temp2
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
46
40
  ```
47
41
 
48
42
  Solution with Stencil
49
43
 
50
44
  ```python
51
45
  c S:
52
- d r(s, h: L) -> N:
53
- i n h o n h.n:
54
- r
55
- s, f = h, h.n
46
+ d m(s, l: O[L], l: O[L]) -> O[L]:
47
+ l, l = l, l
48
+ t = L(0)
49
+ c = t
56
50
 
57
- w f a f.n:
58
- s = s.n
59
- f = f.n.n
60
- s = s.n
61
- p = s.n = N
62
- w s:
63
- t = s.n
64
- s.n = p
65
- p = s
66
- s = t
67
- f, s = h, p
68
- w s:
69
- t, t = f.n, s.n
70
- f.n = s
71
- s.n = t
72
- f, s = t, t
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
73
61
  ```
74
62
 
75
63
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.1.2",
3
+ "version": "1.1.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": {