@scurrlin/stencil 1.4.3 → 1.4.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 +47 -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 3 "Longest Substring Without Repeating Characters":
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 17 "Letter Combinations of a Phone Number":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,17 +22,29 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def lengthOfLongestSubstring(self, s: str) -> int:
26
- charSet = set()
27
- l = 0
28
- res = 0
29
-
30
- for r in range(len(s)):
31
- while s[r] in charSet:
32
- charSet.remove(s[l])
33
- l += 1
34
- charSet.add(s[r])
35
- res = max(res, r - l + 1)
25
+ def letterCombinations(self, digits: str) -> List[str]:
26
+ res = []
27
+ d = digits
28
+ digitToChar = {
29
+ "2": "abc",
30
+ "3": "def",
31
+ "4": "ghi",
32
+ "5": "jkl",
33
+ "6": "mno",
34
+ "7": "qprs",
35
+ "8": "tuv",
36
+ "9": "wxyz",
37
+ }
38
+
39
+ def backtrack(i, curStr):
40
+ if len(curStr) == len(d):
41
+ res.append(curStr)
42
+ return
43
+ for c in digitToChar[d[i]]:
44
+ backtrack(i + 1, curStr + c)
45
+
46
+ if d:
47
+ backtrack(0, "")
36
48
  return res
37
49
  ```
38
50
 
@@ -40,17 +52,29 @@ Solution with Stencil
40
52
 
41
53
  ```python
42
54
  c S:
43
- d l(s, s: s) -> i:
44
- c = s()
45
- l = 0
46
- r = 0
47
-
48
- f r i r(l(s)):
49
- w s[r] i c:
50
- c.r(s[l])
51
- l += 1
52
- c.a(s[r])
53
- r = m(r, r - l + 1)
55
+ d l(s, d: s) -> L[s]:
56
+ r = []
57
+ d = d
58
+ d = {
59
+ "2": "a",
60
+ "3": "d",
61
+ "4": "g",
62
+ "5": "j",
63
+ "6": "m",
64
+ "7": "q",
65
+ "8": "t",
66
+ "9": "w",
67
+ }
68
+
69
+ d b(i, c):
70
+ i l(c) == l(d):
71
+ r.a(c)
72
+ r
73
+ f c i d[d[i]]:
74
+ b(i + 1, c + c)
75
+
76
+ i d:
77
+ b(0, "")
54
78
  r r
55
79
  ```
56
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.4.3",
3
+ "version": "1.4.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": {