hanchu/server/utils.ts
2024-10-23 23:54:41 +07:00

12 lines
350 B
TypeScript

export function wordFactorial(words: string[]): Set<string> {
const combinations: Set<string> = new Set([]);
for (let i = 0; i < words.length; i++) {
let inner = "";
for (let ii = i; ii < words.length; ii++) {
inner += (ii > i ? " " : "") + words[ii].toLowerCase();
combinations.add(inner);
}
}
return combinations;
}