Skip to main content
2 of 2
added 7 characters in body
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 54 53 bytes

k#(a:b:c)=k+last(b:[k*2|a==b])#(b:c)
k#_=k
(#)=<<head

Try it online!

A simple recursion that either doubles the accumulator k or resets it to 1/-1 and adds the values of each step.

nimi
  • 35.9k
  • 4
  • 34
  • 99