permutations
export function permutations<T>(xs: T[]): T[][] { if (xs.length <= 1) return [xs]; return xs.flatMap((x, i) => permutations([...xs.slice(0, i), ...xs.slice(i + 1)]).map((p) => [x, ...p])); }
export function permutations<T>(xs: T[]): T[][] { if (xs.length <= 1) return [xs]; return xs.flatMap((x, i) => permutations([...xs.slice(0, i), ...xs.slice(i + 1)]).map((p) => [x, ...p])); }