Haskell, 54 53 bytes
k#(a:b:c)=k+last(b:[k*2|a==b])#(b:c)
k#_=k
(#)=<<head
A simple recursion that either doubles the accumulator k
or resets it to 1
/-1
and adds the values of each step.
k#(a:b:c)=k+last(b:[k*2|a==b])#(b:c)
k#_=k
(#)=<<head
A simple recursion that either doubles the accumulator k
or resets it to 1
/-1
and adds the values of each step.