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 obone
rotate = lambda data: list(zip(*data[::-1]))
def normalize(data):
data = data.strip().split('\n')
for _ in range(4):
while data[0].count('0') == len(data[0]):
data.pop(0)
data = rotate(data)
return data
def keys_and_locks(lock, some_key):
lock = normalize(lock)
some_key = normalize(some_key)
for _ in range(4):
if lock == some_key:
return True
some_key = rotate(some_key)
return False
July 26, 2019