@scurrlin/stencil 1.9.7 → 1.9.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 +37 -33
  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 60 "Permutation Sequence":
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 61 "Rotate List":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,44 +24,48 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def getPermutation(self, n: int, k: int) -> str:
28
- factorials = [1] * (n + 1)
29
-
30
- for i in range(1, n + 1):
31
- factorials[i] = factorials[i - 1] * i
32
- digits = [str(i) for i in range(1, n + 1)]
33
- k -= 1
34
- result = []
35
-
36
- for i in range(n, 0, -1):
37
- block_size = factorials[i - 1]
38
- index = k // block_size
39
- result.append(digits[index])
40
- digits.pop(index)
41
- k %= block_size
42
- return "".join(result)
27
+ def rotateRight(self, head: ListNode, k: int) -> ListNode:
28
+ if not head:
29
+ return None
30
+ lastElement = head
31
+ length = 1
32
+
33
+ while ( lastElement.next ):
34
+ lastElement = lastElement.next
35
+ length += 1
36
+ k = k % length
37
+ lastElement.next = head
38
+ tempNode = head
39
+
40
+ for _ in range( length - k - 1 ):
41
+ tempNode = tempNode.next
42
+ answer = tempNode.next
43
+ tempNode.next = None
44
+ return answer
43
45
  ```
44
46
 
45
47
  Solution with Stencil
46
48
 
47
49
  ```python
48
50
  c S:
49
- d g(s, n: i, k: i) -> s:
50
- f = [1] * (n + 1)
51
-
52
- f i i r(1, n + 1):
53
- f[i] = f[i - 1] * i
54
- d = [s(i) f i i r(1, n + 1)]
55
- k -= 1
56
- r = []
57
-
58
- f i i r(n, 0, -1):
59
- b_s = f[i - 1]
60
- i = k // b_s
61
- r.a(d[i])
62
- d.p(i)
63
- k %= b_s
64
- r "".j(r)
51
+ d r(s, h: L, k: i) -> L:
52
+ i n h:
53
+ r N
54
+ l = h
55
+ l = 1
56
+
57
+ w ( l.n ):
58
+ l = l.n
59
+ l += 1
60
+ k = k % l
61
+ l.n = h
62
+ t = h
63
+
64
+ f _ i r( l - k - 1 ):
65
+ t = t.n
66
+ a = t.n
67
+ t.n = N
68
+ r a
65
69
  ```
66
70
 
67
71
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.9.7",
3
+ "version": "1.9.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": {