@scurrlin/stencil 1.3.6 → 1.3.8

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 -23
  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 4 "Median of Two Sorted Arrays":
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 6 "Zigzag Conversion":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,34 +22,40 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
26
- totalArray = nums1 + nums2
27
- totalArray.sort()
28
- size = len(totalArray)
29
- if(size % 2 == 0):
30
- size1 = size // 2
31
- size2 = (size // 2) - 1
32
- return (float((totalArray[size1] + totalArray[size2]) / 2 ))
33
- else:
34
- size1 = size // 2
35
- return float(totalArray[size1])
25
+ def convert(self, s: str, numRows: int) -> str:
26
+ if numRows == 1 or numRows >= len(s):
27
+ return s
28
+ res = [''] * numRows
29
+ index, step = 0, 1
30
+
31
+ for c in s:
32
+ res[index] += c
33
+ if index == 0:
34
+ step = 1
35
+ elif index == numRows - 1:
36
+ step = -1
37
+ index += step
38
+ return ''.join(res)
36
39
  ```
37
40
 
38
41
  Solution with Stencil
39
42
 
40
43
  ```python
41
44
  c S:
42
- d f(s, n: L[i], n: L[i]) -> f:
43
- t = n + n
44
- t.s()
45
- s = l(t)
46
- i(s % 2 == 0):
47
- s = s // 2
48
- s = (s // 2) - 1
49
- r (f((t[s] + t[s]) / 2 ))
50
- e:
51
- s = s // 2
52
- r f(t[s])
45
+ d c(s, s: s, n: i) -> s:
46
+ i n == 1 o n >= l(s):
47
+ r s
48
+ r = [''] * n
49
+ i, s = 0, 1
50
+
51
+ f c i s:
52
+ r[i] += c
53
+ i i == 0:
54
+ s = 1
55
+ e i == n - 1:
56
+ s = -1
57
+ i += s
58
+ r ''.j(r)
53
59
  ```
54
60
 
55
61
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
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": {