|
31 | 31 |
|
32 | 32 | ## Solutions |
33 | 33 |
|
| 34 | +- [m1415 v1.py](<../my-submissions/m1415 v1.py>) |
34 | 35 | - [m1415 v2 cursed oneliner expanded.py](<../my-submissions/m1415 v2 cursed oneliner expanded.py>) |
35 | 36 | - [m1415 v2 oneliner.py](<../my-submissions/m1415 v2 oneliner.py>) |
36 | | -- [m1415.py](<../my-submissions/m1415.py>) |
37 | 37 | ### Python |
38 | | -#### [m1415 v2 cursed oneliner expanded.py](<../my-submissions/m1415 v2 cursed oneliner expanded.py>) |
39 | | -```Python |
40 | | -class Solution: |
41 | | - def getHappyString(self, n: int, k: int) -> str: |
42 | | - return ( |
43 | | - _pm_dfs := ( |
44 | | - lambda rem, n, output: |
45 | | - ''.join(output) if not n else |
46 | | - _pm_dfs( |
47 | | - rem - (pot_per_path if (indx := int(rem > (pot_per_path := 2 ** (n - 1)))) else 0), |
48 | | - n - 1, |
49 | | - output + ['abc'.replace(output[-1], '')[indx]] |
50 | | - ) |
51 | | - ) |
52 | | - )( |
53 | | - k - x * pot_n_min_1, |
54 | | - n, |
55 | | - [chr(ord('a') + x)] |
56 | | - ) if (x := (k - 1) // (pot_n_min_1 := 2 ** (n := n - 1))) <= 2 else \ |
57 | | - '' |
58 | | -``` |
59 | | - |
60 | | -#### [m1415 v2 oneliner.py](<../my-submissions/m1415 v2 oneliner.py>) |
61 | | -```Python |
62 | | -class Solution: |
63 | | - def getHappyString(self, n: int, k: int) -> str: |
64 | | - return (_pm_dfs := (lambda rem, n, output: ''.join(output) if not n else _pm_dfs(rem - (pot_per_path if (indx := int(rem > (pot_per_path := 2 ** (n - 1)))) else 0), n - 1, output + ['abc'.replace(output[-1], '')[indx]])))(k - x * pot_n_min_1,n, [chr(ord('a') + x)]) if (x := (k - 1) // (pot_n_min_1 := 2 ** (n := n - 1))) <= 2 else '' |
65 | | -``` |
66 | | - |
67 | | -#### [m1415.py](<../my-submissions/m1415.py>) |
| 38 | +#### [m1415 v1.py](<../my-submissions/m1415 v1.py>) |
68 | 39 | ```Python |
69 | 40 | class Solution: |
70 | 41 | # _pm_dfs stands for premature dfs |
@@ -97,3 +68,32 @@ class Solution: |
97 | 68 |
|
98 | 69 | ``` |
99 | 70 |
|
| 71 | +#### [m1415 v2 cursed oneliner expanded.py](<../my-submissions/m1415 v2 cursed oneliner expanded.py>) |
| 72 | +```Python |
| 73 | +class Solution: |
| 74 | + def getHappyString(self, n: int, k: int) -> str: |
| 75 | + return ( |
| 76 | + _pm_dfs := ( |
| 77 | + lambda rem, n, output: |
| 78 | + ''.join(output) if not n else |
| 79 | + _pm_dfs( |
| 80 | + rem - (pot_per_path if (indx := int(rem > (pot_per_path := 2 ** (n - 1)))) else 0), |
| 81 | + n - 1, |
| 82 | + output + ['abc'.replace(output[-1], '')[indx]] |
| 83 | + ) |
| 84 | + ) |
| 85 | + )( |
| 86 | + k - x * pot_n_min_1, |
| 87 | + n, |
| 88 | + [chr(ord('a') + x)] |
| 89 | + ) if (x := (k - 1) // (pot_n_min_1 := 2 ** (n := n - 1))) <= 2 else \ |
| 90 | + '' |
| 91 | +``` |
| 92 | + |
| 93 | +#### [m1415 v2 oneliner.py](<../my-submissions/m1415 v2 oneliner.py>) |
| 94 | +```Python |
| 95 | +class Solution: |
| 96 | + def getHappyString(self, n: int, k: int) -> str: |
| 97 | + return (_pm_dfs := (lambda rem, n, output: ''.join(output) if not n else _pm_dfs(rem - (pot_per_path if (indx := int(rem > (pot_per_path := 2 ** (n - 1)))) else 0), n - 1, output + ['abc'.replace(output[-1], '')[indx]])))(k - x * pot_n_min_1,n, [chr(ord('a') + x)]) if (x := (k - 1) // (pot_n_min_1 := 2 ** (n := n - 1))) <= 2 else '' |
| 98 | +``` |
| 99 | + |
0 commit comments