Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bruteforce with previous solution solution in Clear category for Staircase by Phil15
import itertools as it
def beat_previous(digits: str) -> int:
start, prev = 0, -1
while True:
for end in range(start + 1, len(digits) + 1):
if prev < (new := int(digits[start:end])):
yield new
start, prev = end, new
break
else:
break
def staircase(digits: str) -> int:
return max(
len([*beat_previous(''.join(it.compress(digits, selectors)))])
for selectors in it.product((True, False), repeat=len(digits))
)
Aug. 7, 2023