more words
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user