Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Square Chest by fed.kz
from itertools import accumulate
def checkio(pairs):
result = 0
def square(radius, start):
values = list(accumulate([start] + [i for i in (1,4,-1,-4) for _ in range(radius)]))
return [[i, j] if i < j else [j, i] for i, j in zip(values, values[1:])]
for start in [i for i in range(12) if i%4]:
for radius in range(1, 4):
result += all(pair in pairs or pair[::-1] in pairs for pair in square(radius, start))
return result
Oct. 13, 2018