export function getSubsets(arr: T[]) { const subsets = [[]] as T[][]; // start with empty set for (const element of arr) { const newSubsets = subsets.map((subset) => [...subset, element]); subsets.push(...newSubsets); } return subsets; }