Skip to content

Commit d7abc8d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9cc1d12 commit d7abc8d

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

strings/secret_language.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66

77
def random_chars() -> str:
8-
'''
8+
"""
99
Generate a random string of 3 ASCII letters.
1010
1111
>>> import random
1212
>>> len(random_chars()) == 3
1313
True
14-
15-
14+
15+
1616
>>> all(c in string.ascii_letters for c in random_chars())
1717
True
18-
19-
20-
21-
'''
22-
return ''.join(random.choices(string.ascii_letters, k=3))
18+
19+
20+
21+
"""
22+
return "".join(random.choices(string.ascii_letters, k=3))
2323

2424

2525
def random_digits() -> str:
@@ -28,13 +28,13 @@ def random_digits() -> str:
2828
2929
>>> len(random_digits()) == 3
3030
True
31-
32-
33-
31+
32+
33+
3434
>>> all(c in string.digits for c in random_digits())
3535
True
3636
"""
37-
return ''.join(random.choices(string.digits, k=3))
37+
return "".join(random.choices(string.digits, k=3))
3838

3939

4040
def encode(code: str) -> str:
@@ -48,15 +48,19 @@ def encode(code: str) -> str:
4848
True
4949
>>> len(encode('hi')) == len('hi') + 12
5050
True
51-
52-
51+
52+
5353
"""
5454
if len(code) >= 3:
5555
code = code[1:] + code[0]
56-
code = random_chars() + random_digits() + code + random_digits() + random_chars()
56+
code = (
57+
random_chars() + random_digits() + code + random_digits() + random_chars()
58+
)
5759
else:
5860
code = code[::-1]
59-
code = random_chars() + random_digits() + code + random_digits() + random_chars()
61+
code = (
62+
random_chars() + random_digits() + code + random_digits() + random_chars()
63+
)
6064
return code
6165

6266

@@ -71,9 +75,9 @@ def decode(code: str) -> str:
7175
'hi'
7276
>>> decode(encode('python'))
7377
'python'
74-
75-
76-
78+
79+
80+
7781
"""
7882
code = code[6:-6]
7983
if len(code) >= 3:
@@ -89,4 +93,4 @@ def decode(code: str) -> str:
8993
decoded = decode(encoded)
9094
print(f"Original → {code}")
9195
print(f"Encoded → {encoded}")
92-
print(f"Decoded → {decoded}")
96+
print(f"Decoded → {decoded}")

0 commit comments

Comments
 (0)