@scurrlin/stencil 1.18.7 → 1.18.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 -51
  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 148 "Sort List":
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 149 "Max Points on a Line":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,62 +24,40 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]:
28
- if not head or not head.next:
29
- return head
30
-
31
- slow, fast = head, head.next
32
- while fast and fast.next:
33
- slow = slow.next
34
- fast = fast.next.next
35
- mid = slow.next
36
- slow.next = None
37
- left = self.sortList(head)
38
- right = self.sortList(mid)
39
- dummy = ListNode(0)
40
- curr = dummy
41
-
42
- while left and right:
43
- if left.val < right.val:
44
- curr.next = left
45
- left = left.next
46
- else:
47
- curr.next = right
48
- right = right.next
49
- curr = curr.next
50
- curr.next = left or right
51
- return dummy.next
27
+ def maxPoints(self, points: List[List[int]]) -> int:
28
+ res = 1
29
+ for i in range(len(points)):
30
+ p1 = points[i]
31
+ count = collections.defaultdict(int)
32
+ for j in range(i + 1, len(points)):
33
+ p2 = points[j]
34
+ if p2[0] == p1[0]:
35
+ slope = float("inf")
36
+ else:
37
+ slope = (p2[1] - p1[1]) / (p2[0] - p1[0])
38
+ count[slope] += 1
39
+ res = max(res, count[slope] + 1)
40
+ return res
52
41
  ```
53
42
 
54
43
  Solution with Stencil
55
44
 
56
45
  ```python
57
46
  c S:
58
- d s(s, h: O[L]) -> O[L]:
59
- i n h o n h.n:
60
- r h
61
-
62
- s, f = h, h.n
63
- w f a f.n:
64
- s = s.n
65
- f = f.n.n
66
- m = s.n
67
- s.n = N
68
- l = s.s(h)
69
- r = s.s(m)
70
- d = L(0)
71
- c = d
72
-
73
- w l a r:
74
- i l.v < r.v:
75
- c.n = l
76
- l = l.n
77
- e:
78
- c.n = r
79
- r = r.n
80
- c = c.n
81
- c.n = l o r
82
- r d.n
47
+ d m(s, p: L[L[i]]) -> i:
48
+ r = 1
49
+ f i i r(l(p)):
50
+ p = p[i]
51
+ c = c.d(i)
52
+ f j i r(i + 1, l(p)):
53
+ p = p[j]
54
+ i p[0] == p[0]:
55
+ s = f("i")
56
+ e:
57
+ s = (p[1] - p[1]) / (p[0] - p[0])
58
+ c[s] += 1
59
+ r = m(r, c[s] + 1)
60
+ r r
83
61
  ```
84
62
 
85
63
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.18.7",
3
+ "version": "1.18.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": {