Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 35 characters in body
Source Link
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python 2 via exit code, 5352 bytes

n=0
for x in input()+[1]:x*n<0>_;n+=x<1or min(1-max(x,-1,n)

Try it online! Try it online!

Successful completion for True, error for False.

-1 byte thanks to Arnauld.

Python 2 exit code, 53 bytes

n=0
for x in input()+[1]:x*n<0>_;n+=x<1or min(1-x,-n)

Try it online!

Successful completion for True, error for False.

Python 2 via exit code, 52 bytes

n=0
for x in input()+[1]:x*n<0>_;n+=x<1or-max(x-1,n)

Try it online!

Successful completion for True, error for False.

-1 byte thanks to Arnauld.

Source Link
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python 2 exit code, 53 bytes

n=0
for x in input()+[1]:x*n<0>_;n+=x<1or min(1-x,-n)

Try it online!

Successful completion for True, error for False.

AltStyle によって変換されたページ (->オリジナル) /