@scurrlin/stencil 1.34.1 → 1.34.4

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 +17 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,64 +16,38 @@ 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 363 "Max Sum of Rectangle No Larger Than K":
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 368 "Largest Divisible Subset":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- from bisect import bisect_left, insort
27
-
28
26
  class Solution:
29
- def maxSumSubmatrix(self, matrix, k):
30
- ans = float("-inf")
31
- m, n = len(matrix), len(matrix[0])
32
- for left in range(n):
33
- rowSums = [0] * m
34
-
35
- for right in range(left, n):
36
- currSum, prefixSums = 0, [0]
37
-
38
- for r in range(m):
39
- rowSums[r] += matrix[r][right]
40
- currSum += rowSums[r]
41
-
42
- idx = bisect_left(prefixSums, currSum - k)
43
-
44
- if idx < len(prefixSums):
45
- ans = max(ans, currSum - prefixSums[idx])
46
- insort(prefixSums, currSum)
27
+ def largestDivisibleSubset(self, nums: List[int]) -> List[int]:
28
+ subsets = {}
29
+ for num in sorted(nums):
30
+ subsets[num] = max(
31
+ [subsets[k] for k in subsets if num % k == 0],
32
+ key = len, default = set()
33
+ ) | {num}
47
34
 
48
- return ans
35
+ return list(max(subsets.values(), key = len))
49
36
  ```
50
37
 
51
38
  Solution with Stencil
52
39
 
53
40
  ```python
54
- f b i b_l, i
55
-
56
41
  c S:
57
- d m(s, m, k):
58
- a = f("-i")
59
- m, n = l(m), l(m[0])
60
- f l i r(n):
61
- r = [0] * m
62
-
63
- f r i r(l, n):
64
- c, p = 0, [0]
65
-
66
- f r i r(m):
67
- r[r] += m[r][r]
68
- c += r[r]
69
-
70
- i = b_l(p, c - k)
71
-
72
- i i < l(p):
73
- a = m(a, c - p[i])
74
- i(p, c)
42
+ d l(s, n: L[i]) -> L[i]:
43
+ s = {}
44
+ f n i s(n):
45
+ s[n] = m(
46
+ [s[k] f k i s i n % k == 0],
47
+ k = l, d = s()
48
+ ) | {n}
75
49
 
76
- r a
50
+ r l(m(s.v(), k = l))
77
51
  ```
78
52
 
79
53
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.34.1",
3
+ "version": "1.34.4",
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": {