Advertisement
Robinlemon

$.LayeredPermutate

Apr 7th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getSummingItems(a,t){
  2.   return a.reduce((h,n) => Object.keys(h)
  3.                                  .reduceRight((m,k) => +k+n <= t ? (m[+k+n] = m[+k+n] ? m[+k+n].concat(m[k].map(sa => sa.concat(n)))
  4.                                                                                       : m[k].map(sa => sa.concat(n)),m)
  5.                                                                  :  m, h), {0:[[]]})[t];
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement