Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
normalize and rotate solution in Clear category for Keys and Locks by juestr
def keys_and_locks(lock, key):
def rot90(x):
return list(zip(*reversed(x)))
def norm(x):
x = x.strip().splitlines()
for i in range(4):
x = rot90(x)
while all(c == '0' for c in x[0]):
x = x[1:]
return x
lock, key = norm(lock), norm(key)
for i in range(4):
if lock == key:
return True
key = rot90(key)
return False
May 18, 2019
Comments: