more words

This commit is contained in:
2026-10-24 13:26:24 -04:00
parent 9e44b07e98
commit 076e70992d
7 changed files with 446 additions and 625 deletions

View File

@@ -53,7 +53,9 @@ export function solveBoard(quartets, maxWords = 30) {
}
if (prefix.length >= 2 && cleanWordSet.has(prefix)) {
if (!foundMap.has(prefix)) {
const existing = foundMap.get(prefix);
// Keep first path found, but a single tile that is a word always wins
if (!existing || (usedIndices.length === 1 && existing.length > 1)) {
foundMap.set(prefix, [...usedIndices]);
}
}
@@ -115,9 +117,12 @@ export function solveBoard(quartets, maxWords = 30) {
return a.word.localeCompare(b.word);
});
// Cap words at maxWords (default: 30)
// Cap words at maxWords (default: 30). Target quartiles and single-tile words
// (tiles that are words on their own) always keep their spot.
if (maxWords && words.length > maxWords) {
words = words.slice(0, maxWords);
const reserved = words.filter(w => w.isTargetQuartile || w.tileCount === 1);
const rest = words.filter(w => !w.isTargetQuartile && w.tileCount !== 1);
words = [...reserved, ...rest.slice(0, Math.max(0, maxWords - reserved.length))];
}
// Final display sorting: Target quartiles first, then points desc, then alphabetical