@scurrlin/stencil 1.29.8 → 1.29.9

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 +27 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,60 +16,44 @@ 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 301 "Remove Invalid Parentheses":
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 303 "Range Sum Query - Immutable":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- class Solution:
27
- def removeInvalidParentheses(self, s: str) -> List[str]:
28
- res = set()
29
- def bt(s, i0, j0, o, c):
30
- count = 0
31
- for i in range(i0, len(s)):
32
- if s[i] == o: count += 1
33
- if s[i] == c: count -= 1
34
- if count >= 0: continue
35
- for j in range(j0, i+1):
36
- if s[j] == c and (j == j0 or s[j-1] != c):
37
- bt(s[:j] + s[j+1:], i, j, o, c)
38
- return
39
- rev = s[::-1]
40
- if o == '(':
41
- bt(rev, 0, 0, ')', '(')
42
- else:
43
- res.add(rev)
44
-
45
- bt(s, 0, 0, '(', ')')
46
- return list(res)
26
+ class NumArray:
27
+ def __init__(self, nums: List[int]):
28
+ self.sum = []
29
+ sum_till = 0
30
+ for i in nums:
31
+ sum_till += i
32
+ self.sum.append(sum_till)
33
+
34
+ def sumRange(self, i: int, j: int) -> int:
35
+ if i > 0 and j > 0:
36
+ return self.sum[j] - self.sum[i - 1]
37
+ else:
38
+ return self.sum[i or j]
47
39
  ```
48
40
 
49
41
  Solution with Stencil
50
42
 
51
43
  ```python
52
- c S:
53
- d r(s, s: s) -> L[s]:
54
- r = s()
55
- d b(s, i, j, o, c):
56
- c = 0
57
- f i i r(i, l(s)):
58
- i s[i] == o: c += 1
59
- i s[i] == c: c -= 1
60
- i c >= 0: c
61
- f j i r(j, i+1):
62
- i s[j] == c a (j == j o s[j-1] != c):
63
- b(s[:j] + s[j+1:], i, j, o, c)
64
- r
65
- r = s[::-1]
66
- i o == '(':
67
- b(r, 0, 0, ')', '(')
68
- e:
69
- r.a(r)
70
-
71
- b(s, 0, 0, '(', ')')
72
- r l(r)
44
+ c N:
45
+ d __i__(s, n: L[i]):
46
+ s.s = []
47
+ s_t = 0
48
+ f i i n:
49
+ s_t += i
50
+ s.s.a(s_t)
51
+
52
+ d s(s, i: i, j: i) -> i:
53
+ i i > 0 a j > 0:
54
+ r s.s[j] - s.s[i - 1]
55
+ e:
56
+ r s.s[i o j]
73
57
  ```
74
58
 
75
59
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.29.8",
3
+ "version": "1.29.9",
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": {