Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursive max solution in Clear category for The Cookie Monster by Phil15
def cookie_monster(piles: list[int], limit: int = float('inf')) -> list[int]:
return max((
[p] + child
for p in set(piles)
if p < limit and (child := cookie_monster(sorted(x - p if x > p else x for x in piles if x != p), p)) is not None
), key=lambda candidate: (-len(candidate), candidate), default=None) if piles else []
Aug. 24, 2023
Comments: