-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypt.py
45 lines (32 loc) · 823 Bytes
/
crypt.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
38
39
40
41
42
43
44
45
def isCryptSolution(crypt, solution):
index = {}
for letter, number in solution:
index[letter] = int(number)
decoded_crypt = []
for word in crypt:
number = 0
for letter in word:
number += index[letter]
number *= 10
number /= 10
if len(word)>1 and number < 10**(len(word) - 1):
return False
decoded_crypt.append(number)
a, b, c = decoded_crypt
return a + b == c
crypt = ["SEND",
"MORE",
"MONEY"]
solution = [["O","0"],
["M","1"],
["Y","2"],
["E","5"],
["N","6"],
["D","7"],
["R","8"],
["S","9"]]
crypt = ["A",
"A",
"A"]
solution = [["A","0"]]
print(isCryptSolution(crypt, solution))