Skip to content

Instantly share code, notes, and snippets.

@sheldonrobinson
Created October 5, 2019 02:12
Show Gist options
  • Save sheldonrobinson/ef433dbde35368a10d417cf3ecec19b4 to your computer and use it in GitHub Desktop.
Save sheldonrobinson/ef433dbde35368a10d417cf3ecec19b4 to your computer and use it in GitHub Desktop.
CodeSignal Solution isCryptSolution
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