Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6),  74  71 bytes

JavaScript (ES6),  74  71 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug
Saved 3 bytes thanks to @tsh

f=([a,...r],k,i=1)=>a?Math.max(...a.map(n=>k&(i+=i)?-1/0:n+f(r,k|i))):0

Try it online!

#JavaScript (ES6),  74  71 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug
Saved 3 bytes thanks to @tsh

f=([a,...r],k,i=1)=>a?Math.max(...a.map(n=>k&(i+=i)?-1/0:n+f(r,k|i))):0

Try it online!

JavaScript (ES6),  74  71 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug
Saved 3 bytes thanks to @tsh

f=([a,...r],k,i=1)=>a?Math.max(...a.map(n=>k&(i+=i)?-1/0:n+f(r,k|i))):0

Try it online!

saved 3 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

#JavaScript (ES6), 74 74  71 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug
Saved 3 bytes thanks to @tsh

f=([a,...r],s=m=r,k,i=1)=>a?Math.max(...a.map(n=>k&(i*=2i+=i)||f?-1/0:n+f(r,~~s+n,k|i))|m:m>s?m):m=s0

Try it online!Try it online!

#JavaScript (ES6), 74 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug

f=([a,...r],s=m=r,k,i=1)=>a?a.map(n=>k&(i*=2)||f(r,~~s+n,k|i))|m:m>s?m:m=s

Try it online!

#JavaScript (ES6),  74  71 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug
Saved 3 bytes thanks to @tsh

f=([a,...r],k,i=1)=>a?Math.max(...a.map(n=>k&(i+=i)?-1/0:n+f(r,k|i))):0

Try it online!

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

#JavaScript (ES6), 74 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug

f=([a,...r],s=m=0s=m=r,k,i=1)=>a+a=>a?a.map(n=>k&(i*=2)||f(r,s+n~~s+n,k|i))|m:m<sm>s?m=s:m:m=s

Try it online!Try it online!

#JavaScript (ES6), 74 bytes

f=([a,...r],s=m=0,k,i=1)=>a+a?a.map(n=>k&(i*=2)||f(r,s+n,k|i))|m:m<s?m=s:m

Try it online!

#JavaScript (ES6), 74 bytes

Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug

f=([a,...r],s=m=r,k,i=1)=>a?a.map(n=>k&(i*=2)||f(r,~~s+n,k|i))|m:m>s?m:m=s

Try it online!

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