@scurrlin/stencil 1.8.7 → 1.8.9

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 +49 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ 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 50 "Pow(x, n)":
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 52 "N-Queens II":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,34 +24,62 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def myPow(self, x: float, n: int) -> float:
28
- def helper(x, n):
29
- if x == 0:
30
- return 0
31
- if n == 0:
32
- return 1
27
+ def totalNQueens(self, n: int) -> int:
28
+ answer = 0
29
+ cols = set()
30
+ posdiag = set()
31
+ negdiag = set()
32
+
33
+ def backtrack(i):
34
+ if i == n:
35
+ nonlocal answer
36
+ answer += 1
37
+ return
33
38
 
34
- res = helper(x * x, n // 2)
35
- return x * res if n % 2 else res
36
- res = helper(x, abs(n))
37
- return res if n >= 0 else 1 / res
39
+ for j in range(n):
40
+ if j in cols or (i + j) in posdiag or (i - j) in negdiag:
41
+ continue
42
+ cols.add(j)
43
+ posdiag.add(i + j)
44
+ negdiag.add(i - j)
45
+ backtrack(i + 1)
46
+ cols.remove(j)
47
+ posdiag.remove(i + j)
48
+ negdiag.remove(i - j)
49
+
50
+ backtrack(0)
51
+ return answer
38
52
  ```
39
53
 
40
54
  Solution with Stencil
41
55
 
42
56
  ```python
43
57
  c S:
44
- d m(s, x: f, n: i) -> f:
45
- d h(x, n):
46
- i x == 0:
47
- r 0
48
- i n == 0:
49
- r 1
58
+ d t(s, n: i) -> i:
59
+ a = 0
60
+ c = s()
61
+ p = s()
62
+ n = s()
63
+
64
+ d b(i):
65
+ i i == n:
66
+ n a
67
+ a += 1
68
+ r
50
69
 
51
- r = h(x * x, n // 2)
52
- r x * r i n % 2 e r
53
- r = h(x, a(n))
54
- r r i n >= 0 e 1 / r
70
+ f j i r(n):
71
+ i j i c o (i + j) i p o (i - j) i n:
72
+ c
73
+ c.a(j)
74
+ p.a(i + j)
75
+ n.a(i - j)
76
+ b(i + 1)
77
+ c.r(j)
78
+ p.r(i + j)
79
+ n.r(i - j)
80
+
81
+ b(0)
82
+ r a
55
83
  ```
56
84
 
57
85
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
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": {