#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
#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