Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 73 bytes

JavaScript (ES6), 73 bytes

Takes input as (annual_returns)(X). The result is 0-indexed.

a=>x=>a.map((_,i)=>x.map((c,j)=>(t=(t+c)*a[i+j])>m&&(r=i,m=t),t=0),m=0)|r

Try it online!

#JavaScript (ES6), 73 bytes

Takes input as (annual_returns)(X). The result is 0-indexed.

a=>x=>a.map((_,i)=>x.map((c,j)=>(t=(t+c)*a[i+j])>m&&(r=i,m=t),t=0),m=0)|r

Try it online!

JavaScript (ES6), 73 bytes

Takes input as (annual_returns)(X). The result is 0-indexed.

a=>x=>a.map((_,i)=>x.map((c,j)=>(t=(t+c)*a[i+j])>m&&(r=i,m=t),t=0),m=0)|r

Try it online!

Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

#JavaScript (ES6), 73 bytes

Takes input as (annual_returns)(X). The result is 0-indexed.

a=>x=>a.map((_,i)=>x.map((c,j)=>(t=(t+c)*a[i+j])>m&&(r=i,m=t),t=0),m=0)|r

Try it online!