Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6 lines proc (commented) solution in Clear category for Ulam-Warburton Automaton Hex by CDG.Axel
def automaton(step: int) -> int:
directions = ((0, -1, 1), (1, -1, 0), (1, 0, -1), (0, 1, -1), (-1, 1, 0), (-1, 0, 1))
switched, around = {(0, 0, 0)}, lambda p: {tuple(a + b for a, b in zip(p, d)) for d in directions}
for _ in range(step - 1):
new = set.union(*map(around, switched)) - switched
switched |= {point for point in new if len(around(point) & switched) == 1}
return len(switched)
# comments for each line
# 2. six directions around point in cube coordinate system
# 3. initial set of switched points and function that return 6 points around given
# 4. on each cycle we add another points
# 5. find all points around each switched point except already switched
# 6. 'switch on' points with only one neighbour between already switched
# 7. result is count of switched points
March 20, 2023
Comments: