-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCubic Tap Code.py
More file actions
44 lines (37 loc) · 1.03 KB
/
Cubic Tap Code.py
File metadata and controls
44 lines (37 loc) · 1.03 KB
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
38
39
40
41
42
43
44
def encode(string):
answer = ""
for char in string:
answer += " "
for i in range(0, len(keys)):
for j in range(0, len(keys[i])):
for k in range(0, len(keys[i][j])):
if char == keys[i][j][k]:
answer += "." * (k+1) + " " + "." * (j+1) + " " + "." * (i+1)
return answer[1:]
def decode(string):
mass = string.split(" ")
answer = ""
for i in range(0, len(mass), 3):
second = len(mass[i])-1
first = len(mass[i+1])-1
key = len(mass[i+2])-1
answer += keys[key][first][second]
return answer
keys = [
[
["A", "B", "C"],
["D", "E", "F"],
["G", "H", "I"]
],
[
["J", "K", "L"],
["M", "N", "O"],
["P", "Q", "R"]
],
[
["S", "T", "U"],
["V", "W", "X"],
["Y", "Z", " "]
]
]
print(decode(".. . ... .. .. . . . ... .. . ..."))