@scurrlin/stencil 1.5.4 → 1.5.6

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 +29 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,13 +8,15 @@
8
8
 
9
9
  ```
10
10
 
11
+ [![npm](https://img.shields.io/npm/dt/%40scurrlin%2Fstencil?style=flat&color=blue)](https://www.npmjs.com/package/@scurrlin/stencil)
12
+
11
13
  ## Overview
12
14
 
13
15
  Whether you are studying for technical interviews, or just starting your coding journey, pattern recognition and memorization are absolutely necessary. It doesn't take a valedictorian to figure that out, but how exactly are you supposed to do that? Between data structures, algorithms, and design patterns, the task of incrementally committing enough of that information to memory can feel impossible. You could spend hours studying fully implemented algorithms only to draw a blank when staring at an empty code editor.
14
16
 
15
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.
16
18
 
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 31 "Next Permutation":
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 32 "Longest Valid Parentheses":
18
20
 
19
21
  ## Example
20
22
 
@@ -22,38 +24,40 @@ Solution
22
24
 
23
25
  ```python
24
26
  class Solution:
25
- def nextPermutation(self, nums: List[int]) -> None:
26
- i = len(nums) - 1
27
+ def longestValidParentheses(self, s: str) -> int:
28
+ max_len = 0
29
+ stack = [-1]
27
30
 
28
- while i > 0 and nums[i-1] >= nums[i]:
29
- i -= 1
30
- if i == 0:
31
- nums.reverse()
32
- return
33
- j = len(nums) - 1
34
- while j >= i and nums[j] <= nums[i-1]:
35
- j -= 1
36
- nums[i-1], nums[j] = nums[j], nums[i-1]
37
- nums[i:] = reversed(nums[i:])
31
+ for i, char in enumerate(s):
32
+ if char == '(':
33
+ stack.append(i)
34
+ else:
35
+ stack.pop()
36
+ if not stack:
37
+ stack.append(i)
38
+ else:
39
+ max_len = max(max_len, i - stack[-1])
40
+ return max_len
38
41
  ```
39
42
 
40
43
  Solution with Stencil
41
44
 
42
45
  ```python
43
46
  c S:
44
- d n(s, n: L[i]) -> N:
45
- i = l(n) - 1
47
+ d l(s, s: s) -> i:
48
+ m_l = 0
49
+ s = [-1]
46
50
 
47
- w i > 0 a n[i-1] >= n[i]:
48
- i -= 1
49
- i i == 0:
50
- n.r()
51
- r
52
- j = l(n) - 1
53
- w j >= i a n[j] <= n[i-1]:
54
- j -= 1
55
- n[i-1], n[j] = n[j], n[i-1]
56
- n[i:] = r(n[i:])
51
+ f i, c i e(s):
52
+ i c == '(':
53
+ s.a(i)
54
+ e:
55
+ s.p()
56
+ i n s:
57
+ s.a(i)
58
+ e:
59
+ m_l = m(m_l, i - s[-1])
60
+ r m_l
57
61
  ```
58
62
 
59
63
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
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": {