@scurrlin/stencil 1.25.5 → 1.25.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 +33 -77
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,98 +16,54 @@ 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 224 "Basic Calculator":
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 225 "Implement Stack using Queues":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- class Solution:
27
- def calculate(self, s: str) -> int:
28
- stack = []
29
- result = 0
30
-
31
- # current sign
32
- sign = 1
33
- i = 0
34
- n = len(s)
35
-
36
- while i < n:
37
- char = s[i]
38
-
39
- if char.isspace():
40
- i += 1
41
- continue
42
-
43
- if char.isdigit():
44
- num = 0
45
- while i < n and s[i].isdigit():
46
- num = num * 10 + int(s[i])
47
- i += 1
48
- result += sign * num
49
- continue
50
-
51
- if char == '+':
52
- sign = 1
53
- elif char == '-':
54
- sign = -1
55
- elif char == '(':
56
- stack.append((result, sign))
57
- result = 0
58
- sign = 1
59
- elif char == ')':
60
- prev_result, prev_sign = stack.pop()
61
- result = prev_result + prev_sign * result
26
+ class MyStack:
27
+
28
+ def __init__(self):
29
+ self.q = deque()
30
+
31
+ def push(self, x: int) -> None:
32
+ self.q.append(x)
33
+ for _ in range(len(self.q) - 1):
34
+ self.q.append(self.q.popleft())
35
+
36
+ def pop(self) -> int:
37
+ return self.q.popleft()
62
38
 
63
- i += 1
39
+ def top(self) -> int:
40
+ return self.q[0]
64
41
 
65
- return result
42
+ def empty(self) -> bool:
43
+ return len(self.q) == 0
66
44
  ```
67
45
 
68
46
  Solution with Stencil
69
47
 
70
48
  ```python
71
- c S:
72
- d c(s, s: s) -> i:
73
- s = []
74
- r = 0
75
-
76
- # c s
77
- s = 1
78
- i = 0
79
- n = l(s)
80
-
81
- w i < n:
82
- c = s[i]
83
-
84
- i c.i():
85
- i += 1
86
- c
87
-
88
- i c.i():
89
- n = 0
90
- w i < n a s[i].i():
91
- n = n * 1 + i(s[i])
92
- i += 1
93
- r += s * n
94
- c
95
-
96
- i c == '+':
97
- s = 1
98
- e c == '-':
99
- s = -1
100
- e c == '(':
101
- s.a((r, s))
102
- r = 0
103
- s = 1
104
- e c == ')':
105
- p_r, p_s = s.p()
106
- r = p_r + p_s * r
49
+ c M:
50
+
51
+ d __i__(s):
52
+ s.q = d()
53
+
54
+ d p(s, x: i) -> N:
55
+ s.q.a(x)
56
+ f _ i r(l(s.q) - 1):
57
+ s.q.a(s.q.p())
58
+
59
+ d p(s) -> i:
60
+ r s.q.p()
107
61
 
108
- i += 1
62
+ d t(s) -> i:
63
+ r s.q[0]
109
64
 
110
- r r
65
+ d e(s) -> b:
66
+ r l(s.q) == 0
111
67
  ```
112
68
 
113
69
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.25.5",
3
+ "version": "1.25.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": {