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

specified output
Source Link
Riolku
  • 451
  • 2
  • 4

Python 3, 87(削除) 96 (削除ここまで)(削除) 87 (削除ここまで) 85 bytes

def f(a):
	c=p=0
	for x in a:
		if p*x:return
		p|=x;c+=1
		if c>=p>0:c=p=0
	return p<1p

Try it online! Try it online!

-5 bytes thanks to 79037662.

-6 bytes thanks to HyperNeutrino.

None and positive are falsy, 0 is truthy.

Python 3, 87 bytes

def f(a):
	c=p=0
	for x in a:
		if p*x:return
		p|=x;c+=1
		if c>=p>0:c=p=0
	return p<1

Try it online!

Python 3, (削除) 96 (削除ここまで)(削除) 87 (削除ここまで) 85 bytes

def f(a):
	c=p=0
	for x in a:
		if p*x:return
		p|=x;c+=1
		if c>=p>0:c=p=0
	return p

Try it online!

-5 bytes thanks to 79037662.

-6 bytes thanks to HyperNeutrino.

None and positive are falsy, 0 is truthy.

fixed second if statement
Source Link
Riolku
  • 451
  • 2
  • 4

Python 3, 9687 bytes

def f(a,c=0,p=0):
	c=p=0
	for x in a:
		if p and xp*x:return
		p|=x;c+=1
		if p and c>=pc>=p>0:c=p=0
	return p<1

Try it online! Try it online!

Python 3, 96 bytes

def f(a,c=0,p=0):
	for x in a:
		if p and x:return
		p|=x;c+=1
		if p and c>=p:c=p=0
	return p<1

Try it online!

Python 3, 87 bytes

def f(a):
	c=p=0
	for x in a:
		if p*x:return
		p|=x;c+=1
		if c>=p>0:c=p=0
	return p<1

Try it online!

Source Link
Riolku
  • 451
  • 2
  • 4

Python 3, 96 bytes

def f(a,c=0,p=0):
	for x in a:
		if p and x:return
		p|=x;c+=1
		if p and c>=p:c=p=0
	return p<1

Try it online!

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