Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ulam-Warburton Automaton Hex by tokiojapan55
def automaton(step: int) -> int:
def neighbors(x, y):
for xx, yy in [(0, 1), (1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1)]:
yield (x + xx, y + yy)
born, dots = [(0, 0)], [(0, 0)]
for i in range(step - 1):
new_born, new_dots = [], dots[:]
for x, y in born:
for xx, yy in neighbors(x, y):
cnt = 0
for xxx, yyy in neighbors(xx, yy):
if (xxx, yyy) in dots:
cnt += 1
if cnt == 1:
new_born.append((xx, yy))
new_dots.append((xx, yy))
born, dots = new_born, new_dots
return len(dots)
Feb. 16, 2023
Comments: