@scurrlin/stencil 1.4.1 → 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 +45 -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 8 "String to Integer (atoi)":
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,52 +22,56 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def myAtoi(self, s: str) -> int:
26
- s = s.strip()
27
- if not s:
28
- return 0
29
-
30
- sign, i, res = 1, 0, 0
31
- if s[0] == '-':
32
- sign = -1
33
- i += 1
34
- elif s[0] == '+':
35
- i += 1
36
-
37
- while i < len(s) and s[i].isdigit():
38
- res = res * 10 + int(s[i])
39
- if sign * res > 2 ** 31 - 1:
40
- return 2 ** 31 - 1
41
- if sign * res < -2 ** 31:
42
- return -2 ** 31
43
- i += 1
44
- return sign * res
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
46
+ return res
45
47
  ```
46
48
 
47
49
  Solution with Stencil
48
50
 
49
51
  ```python
50
52
  c S:
51
- d m(s, s: s) -> i:
52
- s = s.s()
53
- i n s:
54
- r 0
55
-
56
- s, i, r = 1, 0, 0
57
- i s[0] == '-':
58
- s = -1
59
- i += 1
60
- e s[0] == '+':
61
- i += 1
62
-
63
- w i < l(s) a s[i].i():
64
- r = r * 1 + i(s[i])
65
- i s * r > 2 ** 3 - 1:
66
- r 2 ** 3 - 1
67
- i s * r < -2 ** 3:
68
- r -2 ** 3
69
- i += 1
70
- r s * r
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
74
+ r r
71
75
  ```
72
76
 
73
77
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.4.1",
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": {