@scurrlin/stencil 1.27.5 → 1.27.7

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 -27
  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 257 "Binary Tree Paths":
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 260 "Single Number III":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,40 +24,42 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def binaryTreePaths(self, root: Optional[TreeNode]) -> List[str]:
28
- def dfs(node, path, result):
29
- if not node:
30
- return
31
- path += str(node.val)
32
- if not node.left and not node.right:
33
- result.append(path)
27
+ def singleNumber(self, nums: list[int]) -> list[int]:
28
+ xor = 0
29
+ for num in nums:
30
+ xor ^= num
31
+
32
+ set_bit = xor & -xor
33
+
34
+ a, b = 0, 0
35
+ for num in nums:
36
+ if num & set_bit:
37
+ a ^= num
34
38
  else:
35
- dfs(node.left, path + '->', result)
36
- dfs(node.right, path + '->', result)
37
-
38
- result = []
39
- dfs(root, '', result)
40
- return result
39
+ b ^= num
40
+
41
+ return [a, b]
41
42
  ```
42
43
 
43
44
  Solution with Stencil
44
45
 
45
46
  ```python
46
47
  c S:
47
- d b(s, r: O[T]) -> L[s]:
48
- d d(n, p, r):
49
- i n n:
50
- r
51
- p += s(n.v)
52
- i n n.l a n n.r:
53
- r.a(p)
48
+ d s(s, n: l[i]) -> l[i]:
49
+ x = 0
50
+ f n i n:
51
+ x ^= n
52
+
53
+ s_b = x & -x
54
+
55
+ a, b = 0, 0
56
+ f n i n:
57
+ i n & s_b:
58
+ a ^= n
54
59
  e:
55
- d(n.l, p + '->', r)
56
- d(n.r, p + '->', r)
57
-
58
- r = []
59
- d(r, '', r)
60
- r r
60
+ b ^= n
61
+
62
+ r [a, b]
61
63
  ```
62
64
 
63
65
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.27.5",
3
+ "version": "1.27.7",
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": {