@scurrlin/stencil 1.4.6 → 1.4.8

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 +53 -23
  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 23 "Merge K Sorted Lists":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,42 +22,72 @@ 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
-
25
+ def mergeKLists(self, lists: List[ListNode]) -> ListNode:
26
+ if not lists or len(lists) == 0:
27
+ return None
28
+
29
+ while len(lists) > 1:
30
+ mergedLists = []
31
+ for i in range(0, len(lists), 2):
32
+ l1 = lists[i]
33
+ l2 = lists[i + 1] if (i + 1) < len(lists) else None
34
+ mergedLists.append(self.mergeList(l1, l2))
35
+ lists = mergedLists
36
+ return lists[0]
37
+
38
+ def mergeList(self, l1, l2):
39
+ dummy = ListNode()
40
+ tail = dummy
41
+
30
42
  while l1 and l2:
31
- if l1.val <= l2.val:
32
- current.next = l1
43
+ if l1.val < l2.val:
44
+ tail.next = l1
33
45
  l1 = l1.next
34
46
  else:
35
- current.next = l2
47
+ tail.next = l2
36
48
  l2 = l2.next
37
- current = current.next
38
- current.next = l1 if l1 else l2
39
- return temp.next
49
+ tail = tail.next
50
+ if l1:
51
+ tail.next = l1
52
+ if l2:
53
+ tail.next = l2
54
+ return dummy.next
40
55
  ```
41
56
 
42
57
  Solution with Stencil
43
58
 
44
59
  ```python
45
60
  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
-
61
+ d m(s, l: L[L]) -> L:
62
+ i n l o l(l) == 0:
63
+ r N
64
+
65
+ w l(l) > 1:
66
+ m = []
67
+ f i i r(0, l(l), 2):
68
+ l = l[i]
69
+ l = l[i + 1] i (i + 1) < l(l) e N
70
+ m.a(s.m(l, l))
71
+ l = m
72
+ r l[0]
73
+
74
+ d m(s, l, l):
75
+ d = L()
76
+ t = d
77
+
51
78
  w l a l:
52
- i l.v <= l.v:
53
- c.n = l
79
+ i l.v < l.v:
80
+ t.n = l
54
81
  l = l.n
55
82
  e:
56
- c.n = l
83
+ t.n = l
57
84
  l = l.n
58
- c = c.n
59
- c.n = l i l e l
60
- r t.n
85
+ t = t.n
86
+ i l:
87
+ t.n = l
88
+ i l:
89
+ t.n = l
90
+ r d.n
61
91
  ```
62
92
 
63
93
  ## 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.8",
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": {