Skip to content

Commit d5b7d0a

Browse files
Zanger67/leetcodeZanger67/leetcode
authored andcommitted
Updated markdown files
1 parent 15d25b7 commit d5b7d0a

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

markdowns/_1415. The k-th Lexicographical String of All Happy Strings of Length n.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,11 @@
3131

3232
## Solutions
3333

34+
- [m1415 v1.py](<../my-submissions/m1415 v1.py>)
3435
- [m1415 v2 cursed oneliner expanded.py](<../my-submissions/m1415 v2 cursed oneliner expanded.py>)
3536
- [m1415 v2 oneliner.py](<../my-submissions/m1415 v2 oneliner.py>)
36-
- [m1415.py](<../my-submissions/m1415.py>)
3737
### 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>)
6839
```Python
6940
class Solution:
7041
# _pm_dfs stands for premature dfs
@@ -97,3 +68,32 @@ class Solution:
9768

9869
```
9970

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

Comments
 (0)