Created
October 5, 2019 02:12
-
-
Save sheldonrobinson/ef433dbde35368a10d417cf3ecec19b4 to your computer and use it in GitHub Desktop.
CodeSignal Solution isCryptSolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decrypt(word, dictionary): | |
lst =[] | |
for c in word: | |
lst.append(dictionary[c]) | |
return ''.join(lst) | |
def isCryptSolution(crypt, solution): | |
dict = {} | |
for r in solution: | |
dict[r[0]] = r[1] | |
values = [0]*3 | |
for i in range(3): | |
val = decrypt(crypt[i], dict) | |
if val.startswith('0') and len(val) > 1: | |
return False | |
values[i] = int(val) | |
return (values[0]+values[1]) == values[2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment