Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
universal solution for any grid size solution in Clear category for The Square Chest by vit.aborigen
GRID_SIZE = 4
def all_possible_solutions(n):
side = n - 1
while side:
for start in range(1, n - side + 1):
for end in range(n - side):
delta = range(side + 1)
top = [(start + x + end * n, start + y + end * n) for x, y in zip(delta, delta[1:])]
bottom = [(start + x + end * n + n * side, start + y + end * n + n * side) for x, y in zip(delta, delta[1:])]
left = [(start + x * n + end * n, start + y * n + end * n) for x, y in zip(delta, delta[1:])]
right = [(start + x * n + end * n + side, start + y * n + end * n + side) for x, y in zip(delta, delta[1:])]
yield top + bottom + left + right
side -= 1
def checkio(lines_list) -> int:
lines_list = {tuple(sorted(v)) for v in lines_list}
counter = [(set(square) - lines_list) for square in all_possible_solutions(GRID_SIZE)]
return counter.count(set())
Nov. 18, 2018
Comments: