@scurrlin/stencil 1.28.2 → 1.28.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 +25 -71
  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 273 "Integer to English Words":
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 275 "H-Index II":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,82 +24,36 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def numberToWords(self, num: int) -> str:
28
- if num == 0:
29
- return "Zero"
30
-
31
- bigString = ["Thousand", "Million", "Billion"]
32
- result = self.numberToWordsHelper(num % 1000)
33
- num //= 1000
34
-
35
- for i in range(len(bigString)):
36
- if num > 0 and num % 1000 > 0:
37
- result = self.numberToWordsHelper(num % 1000) + bigString[i] + " " + result
38
- num //= 1000
39
-
40
- return result.strip()
41
-
42
- def numberToWordsHelper(self, num: int) -> str:
43
- digitString = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
44
- teenString = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]
45
- tenString = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]
46
-
47
- result = ""
48
- if num > 99:
49
- result += digitString[num // 100] + " Hundred "
50
-
51
- num %= 100
52
- if num < 20 and num > 9:
53
- result += teenString[num - 10] + " "
54
- else:
55
- if num >= 20:
56
- result += tenString[num // 10] + " "
57
- num %= 10
58
- if num > 0:
59
- result += digitString[num] + " "
60
-
61
- return result
27
+ def hIndex(self, citations: List[int]) -> int:
28
+ n = len(citations)
29
+ left, right = 0, n - 1
30
+ while left <= right:
31
+ mid = (left + right) // 2
32
+ if citations[mid] == n - mid:
33
+ return n - mid
34
+ elif citations[mid] < n - mid:
35
+ left = mid + 1
36
+ else:
37
+ right = mid - 1
38
+ return n - left
62
39
  ```
63
40
 
64
41
  Solution with Stencil
65
42
 
66
43
  ```python
67
44
  c S:
68
- d n(s, n: i) -> s:
69
- i n == 0:
70
- r "Z"
71
-
72
- b = ["T", "M", "B"]
73
- r = s.n(n % 1)
74
- n //= 1
75
-
76
- f i i r(l(b)):
77
- i n > 0 a n % 1 > 0:
78
- r = s.n(n % 1) + b[i] + " " + r
79
- n //= 1
80
-
81
- r r.s()
82
-
83
- d n(s, n: i) -> s:
84
- d = ["Z", "O", "T", "T", "F", "F", "S", "S", "E", "N"]
85
- t = ["T", "E", "T", "T", "F", "F", "S", "S", "E", "N"]
86
- t = ["", "", "T", "T", "F", "F", "S", "S", "E", "N"]
87
-
88
- r = ""
89
- i n > 9:
90
- r += d[n // 1] + " H "
91
-
92
- n %= 1
93
- i n < 2 a n > 9:
94
- r += t[n - 1] + " "
95
- e:
96
- i n >= 2:
97
- r += t[n // 1] + " "
98
- n %= 1
99
- i n > 0:
100
- r += d[n] + " "
101
-
102
- r r
45
+ d h(s, c: L[i]) -> i:
46
+ n = l(c)
47
+ l, r = 0, n - 1
48
+ w l <= r:
49
+ m = (l + r) // 2
50
+ i c[m] == n - m:
51
+ r n - m
52
+ e c[m] < n - m:
53
+ l = m + 1
54
+ e:
55
+ r = m - 1
56
+ r n - l
103
57
  ```
104
58
 
105
59
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.28.2",
3
+ "version": "1.28.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": {