-
Notifications
You must be signed in to change notification settings - Fork 0
/
2325.py
37 lines (28 loc) · 871 Bytes
/
2325.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Solution:
def decodeMessage(self, key: str, message: str) -> str:
table = {}
alphabet_position = 0
result = []
key = key
for i in range(len(key)):
if key[i] == " ":
continue
if table.get(key[i]) is not None:
continue
table[key[i]] = chr(alphabet_position + 97)
alphabet_position += 1
for chunk in message.split(" "):
word = ""
for char in chunk:
if char == " ":
word += " "
continue
else:
word += table.get(char)
result.append(word)
return " ".join(result)
print(
Solution().decodeMessage(
key="the quick brown fox jumps over the lazy dog", message="vkbs bs t suepuv"
)
)