@scurrlin/stencil 1.4.0 → 1.4.2

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 +43 -19
  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 7 "Reverse Integer":
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 15 "3Sum":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,15 +22,27 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def reverse(self, x: int) -> int:
26
- res = 0
27
-
28
- if x < 0:
29
- res = int(str(x)[1:][::-1]) * -1
30
- else:
31
- res = int(str(x)[::-1])
32
- if res > 2 ** 31 - 1 or res < -2 ** 31:
33
- return 0
25
+ def threeSum(self, nums: List[int]) -> List[List[int]]:
26
+ res = []
27
+ n = nums
28
+ n.sort()
29
+
30
+ for i in range(len(n)):
31
+ if i > 0 and n[i] == n[i - 1]:
32
+ continue
33
+ j = i + 1
34
+ k = len(n) - 1
35
+ while j < k:
36
+ total = n[i] + n[j] + n[k]
37
+ if total < 0:
38
+ j += 1
39
+ elif total > 0:
40
+ k -= 1
41
+ else:
42
+ res.append([n[i], n[j], n[k]])
43
+ j += 1
44
+ while j < k and n[j] == n[j - 1]:
45
+ j += 1
34
46
  return res
35
47
  ```
36
48
 
@@ -38,15 +50,27 @@ Solution with Stencil
38
50
 
39
51
  ```python
40
52
  c S:
41
- d r(s, x: i) -> i:
42
- r = 0
43
-
44
- i x < 0:
45
- r = i(s(x)[1:][::-1]) * -1
46
- e:
47
- r = i(s(x)[::-1])
48
- i r > 2 ** 3 - 1 o r < -2 ** 3:
49
- r 0
53
+ d t(s, n: L[i]) -> L[L[i]]:
54
+ r = []
55
+ n = n
56
+ n.s()
57
+
58
+ f i i r(l(n)):
59
+ i i > 0 a n[i] == n[i - 1]:
60
+ c
61
+ j = i + 1
62
+ k = l(n) - 1
63
+ w j < k:
64
+ t = n[i] + n[j] + n[k]
65
+ i t < 0:
66
+ j += 1
67
+ e t > 0:
68
+ k -= 1
69
+ e:
70
+ r.a([n[i], n[j], n[k]])
71
+ j += 1
72
+ w j < k a n[j] == n[j - 1]:
73
+ j += 1
50
74
  r r
51
75
  ```
52
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
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": {