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

Haskell, 5454 53 bytes

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

Try it online!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.

Haskell, 54 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.

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.

Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 54 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.