Skip to main content
added 11 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 3, 57 56 bytes

-1 byfebyte thanks to @notjagan

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(m*2)**(a==s[0])))

Try it online!

Python 3, 57 56 bytes

-1 byfe thanks to @notjagan

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(m*2)**(a==s[0])))

Try it online!

Python 3, 57 56 bytes

-1 byte thanks to @notjagan

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(m*2)**(a==s[0])))

Try it online!

added 39 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 3, 5757 56 bytes

-1 byfe thanks to @notjagan

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(m*2)**(a==s[0])*m*2or 1))

Try it online!Try it online!

Python 3, 57 bytes

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(a==s[0])*m*2or 1))

Try it online!

Python 3, 57 56 bytes

-1 byfe thanks to @notjagan

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(m*2)**(a==s[0])))

Try it online!

Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 3, 57 bytes

f=lambda a,*s,m=1:m*a+(s>()and f(*s,m=(a==s[0])*m*2or 1))

Try it online!