Skip to main content
deleted 15 characters in body
Source Link
S.S. Anne
  • 3.4k
  • 11
  • 31

C (gcc), 4838 bytes

r;fb;f(a,lint*a)int*a;{forb=(r=0;l--;b=*a++)r+=*a%2*~?b%2*~-*a++;l=r;b+f(a):0;} 

Input as an0-terminated array a and its length l.

Try it online! Recursive function.

-10 bytes thanks to Arnauld!

Try it online!

C (gcc), 48 bytes

r;f(a,l)int*a;{for(r=0;l--;)r+=*a%2*~-*a++;l=r;} 

Input as an array a and its length l.

Try it online!

C (gcc), 38 bytes

b;f(int*a){b=(b=*a++)?b%2*~-b+f(a):0;} 

Input as 0-terminated array a.

Recursive function.

-10 bytes thanks to Arnauld!

Try it online!

Source Link
S.S. Anne
  • 3.4k
  • 11
  • 31

C (gcc), 48 bytes

r;f(a,l)int*a;{for(r=0;l--;)r+=*a%2*~-*a++;l=r;} 

Input as an array a and its length l.

Try it online!