Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 108 bytes

JavaScript (ES6), 108 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>1/r[(y=[...y]).push(x)]||eval(y.join`+`)-n?y:r=y)],[[]],r=!n&&[])&&r

Try it online!

#JavaScript (ES6), 108 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>1/r[(y=[...y]).push(x)]||eval(y.join`+`)-n?y:r=y)],[[]],r=!n&&[])&&r

Try it online!

JavaScript (ES6), 108 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>1/r[(y=[...y]).push(x)]||eval(y.join`+`)-n?y:r=y)],[[]],r=!n&&[])&&r

Try it online!

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

#JavaScript (ES6), 111108 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>y=>1/r[(b=[y=[...y,x],1/r[by]).length]||evalpush(bx)]||eval(y.join`+`)-n?by:r=b)r=y)],[[]],r=!n&&[])&&r

Try it online!Try it online!

#JavaScript (ES6), 111 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>(b=[...y,x],1/r[b.length]||eval(b.join`+`)-n?b:r=b))],[[]],r=!n&&[])&&r

Try it online!

#JavaScript (ES6), 108 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>1/r[(y=[...y]).push(x)]||eval(y.join`+`)-n?y:r=y)],[[]],r=!n&&[])&&r

Try it online!

saved 8 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

#JavaScript (ES6), 119111 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce(m=(a,x)=>[...a,...a.map(y=>(b=[...y,x],eval1/r[b.length]||eval(b.join`+`)-n|m>(l=b.length)n?b:(m=l,r=b)))],[[]],r=!n&&[])&&r

Try it online!Try it online!

#JavaScript (ES6), 119 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce(m=(a,x)=>[...a,...a.map(y=>(b=[...y,x],eval(b.join`+`)-n|m>(l=b.length)?b:(m=l,r=b)))],[[]],r=!n&&[])&&r

Try it online!

#JavaScript (ES6), 111 bytes

Takes input as (array)(n). Returns either an array or false.

a=>n=>a.reduce((a,x)=>[...a,...a.map(y=>(b=[...y,x],1/r[b.length]||eval(b.join`+`)-n?b:r=b))],[[]],r=!n&&[])&&r

Try it online!

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