Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Cut zero-lines then numpy.rot90() solution in 3rd party category for Keys and Locks by quarkov
from numpy import array, rot90, array_equal
def keys_and_locks(lock, key):
lock = array([list(line) for line in lock.split() if "#" in line])
key = array([list(line) for line in key.split() if "#" in line])
lock, key = rot90(lock), rot90(key)
lock = array([line for line in lock if "#" in line])
key = array([line for line in key if "#" in line])
return any(array_equal(lock, rot90(key, i)) for i in range(4))
# thanks flpo for array_equal method, it saves a lot of space
Sept. 16, 2018
Comments: