hanchu/server/utils.ts

12 lines
350 B
TypeScript
Raw Permalink Normal View History

2024-10-23 16:54:41 +00:00
export function wordFactorial(words: string[]): Set<string> {
const combinations: Set<string> = new Set([]);
2024-10-22 04:35:21 +00:00
for (let i = 0; i < words.length; i++) {
2024-10-23 16:54:41 +00:00
let inner = "";
2024-10-22 04:35:21 +00:00
for (let ii = i; ii < words.length; ii++) {
2024-10-23 16:54:41 +00:00
inner += (ii > i ? " " : "") + words[ii].toLowerCase();
combinations.add(inner);
2024-10-22 04:35:21 +00:00
}
}
return combinations;
}