@scurrlin/stencil 1.33.6 → 1.33.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 +54 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,46 +16,72 @@ 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 350 "Intersection of Two Arrays 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 352 "Data Stream as Disjoint Intervals":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- class Solution:
27
- def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
28
- nums1.sort(), nums2.sort()
29
- i, j, result = 0, 0, []
30
- while i < len(nums1) and j < len(nums2):
31
- if nums1[i] == nums2[j]:
32
- result.append(nums1[i])
33
- i += 1
34
- j += 1
35
- elif nums1[i] < nums2[j]:
36
- i += 1
37
- else:
38
- j += 1
39
- return result
26
+ class SummaryRanges:
27
+
28
+ def __init__(self):
29
+ self.nums = set()
30
+
31
+ def addNum(self, value: int) -> None:
32
+ self.nums.add(value)
33
+
34
+ def getIntervals(self) -> List[List[int]]:
35
+ intervals = []
36
+ seen = set()
37
+ for num in self.nums:
38
+ if num in seen:
39
+ continue
40
+
41
+ left = num
42
+ while left - 1 in self.nums:
43
+ left -= 1
44
+ seen.add(left)
45
+
46
+ right = num
47
+ while right + 1 in self.nums:
48
+ right += 1
49
+ seen.add(right)
50
+
51
+ intervals.append([left, right])
52
+ return sorted(intervals)
40
53
  ```
41
54
 
42
55
  Solution with Stencil
43
56
 
44
57
  ```python
45
58
  c S:
46
- d i(s, n: L[i], n: L[i]) -> L[i]:
47
- n.s(), n.s()
48
- i, j, r = 0, 0, []
49
- w i < l(n) a j < l(n):
50
- i n[i] == n[j]:
51
- r.a(n[i])
52
- i += 1
53
- j += 1
54
- e n[i] < n[j]:
55
- i += 1
56
- e:
57
- j += 1
58
- r r
59
+
60
+ d __i__(s):
61
+ s.n = s()
62
+
63
+ d a(s, v: i) -> N:
64
+ s.n.a(v)
65
+
66
+ d g(s) -> L[L[i]]:
67
+ i = []
68
+ s = s()
69
+ f n i s.n:
70
+ i n i s:
71
+ c
72
+
73
+ l = n
74
+ w l - 1 i s.n:
75
+ l -= 1
76
+ s.a(l)
77
+
78
+ r = n
79
+ w r + 1 i s.n:
80
+ r += 1
81
+ s.a(r)
82
+
83
+ i.a([l, r])
84
+ r s(i)
59
85
  ```
60
86
 
61
87
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.33.6",
3
+ "version": "1.33.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": {