Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Oneliner solution in Speedy category for Ulam–Warburton Automaton by maelnor
def automaton(step: int) -> int:
return int(sum(3 ** bin(n).count('1') for n in range(step)) * 4 / 3 - 1 / 3)
print("Example:")
print(automaton(2))
# These "asserts" are used for self-checking
assert automaton(1) == 1
assert automaton(2) == 5
assert automaton(3) == 9
assert automaton(4) == 21
assert automaton(5) == 25
print("The mission is done! Click 'Check Solution' to earn rewards!")
Aug. 5, 2024