Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Combinations solution in Clear category for Staircase by Serg900vd
from itertools import combinations
def beat_previous(digits: str) -> list[int]:
res, stack = [-1], ''
for d in digits:
stack += d
if int(stack) > res[-1]:
res.append(int(stack))
stack = ''
return res[1:]
def staircase(digits: str) -> int:
return max(max(len(beat_previous(item)) for item in combinations(digits, r)) for r in range(len(digits)))
Aug. 9, 2023