UNPKG

ziko

Version:

A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...

15 lines 446 B
const powerSet=originalSet=>{ const subSets = []; const NUMBER_OF_COMBINATIONS = 2 ** originalSet.length; for (let i = 0; i < NUMBER_OF_COMBINATIONS; i += 1) { const subSet = []; for (let j = 0; j < originalSet.length; j += 1) { if (i & (1 << j)) { subSet.push(originalSet[j]); } } subSets.push(subSet); } return subSets; } export{powerSet}