@scurrlin/stencil 1.33.8 → 1.33.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 +71 -23
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,40 +16,88 @@ 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 354 "Russian Doll Envelopes":
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 355 "Design Twitter":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- class Solution:
27
- def maxEnvelopes(self, envelopes: List[List[int]]) -> int:
28
- envelopes.sort(key = lambda x: (x[0], -x[1]))
29
- res = []
30
- for _, h in envelopes:
31
- idx = bisect_left(res, h)
32
- if idx == len(res):
33
- res.append(h)
34
- else:
35
- res[idx] = h
36
- return len(res)
26
+ from collections import defaultdict
27
+ import heapq
28
+
29
+ class Twitter:
30
+
31
+ def __init__(self):
32
+ self.time = 0
33
+ self.followers = defaultdict(set)
34
+ self.hist = defaultdict(set)
35
+
36
+ def postTweet(self, userId: int, tweetId: int) -> None:
37
+ self.followers[userId].add(userId)
38
+ self.hist[userId].add((-self.time, tweetId))
39
+ self.time += 1
40
+
41
+ def getNewsFeed(self, userId: int) -> List[int]:
42
+ feed = []
43
+ for followee in self.followers[userId]:
44
+ for post in self.hist[followee]:
45
+ heapq.heappush(feed, post)
46
+
47
+ res = []
48
+ for _ in range(10):
49
+ if not feed:
50
+ break
51
+ _, postId = heapq.heappop(feed)
52
+ res.append(postId)
53
+
54
+ return res
55
+
56
+ def follow(self, followerId: int, followeeId: int) -> None:
57
+ self.followers[followerId].add(followeeId)
58
+
59
+ def unfollow(self, followerId: int, followeeId: int) -> None:
60
+ self.followers[followerId].discard(followeeId)
37
61
  ```
38
62
 
39
63
  Solution with Stencil
40
64
 
41
65
  ```python
42
- c S:
43
- d m(s, e: L[L[i]]) -> i:
44
- e.s(k = l x: (x[0], -x[1]))
45
- r = []
46
- f _, h i e:
47
- i = b_l(r, h)
48
- i i == l(r):
49
- r.a(h)
50
- e:
51
- r[i] = h
52
- r l(r)
66
+ f c i d
67
+ i h
68
+
69
+ c T:
70
+
71
+ d __i__(s):
72
+ s.t = 0
73
+ s.f = d(s)
74
+ s.h = d(s)
75
+
76
+ d p(s, u: i, t: i) -> N:
77
+ s.f[u].a(u)
78
+ s.h[u].a((-s.t, t))
79
+ s.t += 1
80
+
81
+ d g(s, u: i) -> L[i]:
82
+ f = []
83
+ f f i s.f[u]:
84
+ f p i s.h[f]:
85
+ h.h(f, p)
86
+
87
+ r = []
88
+ f _ i r(1):
89
+ i n f:
90
+ b
91
+ _, p = h.h(f)
92
+ r.a(p)
93
+
94
+ r r
95
+
96
+ d f(s, f: i, f: i) -> N:
97
+ s.f[f].a(f)
98
+
99
+ d u(s, f: i, f: i) -> N:
100
+ s.f[f].d(f)
53
101
  ```
54
102
 
55
103
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.33.8",
3
+ "version": "1.33.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": {