scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
20 lines (14 loc) • 451 B
text/typescript
import { type Cell } from '@scrabble-solver/types';
export const generateEndIndices = (cells: Cell[], startIndex: number): number[] => {
if (cells.length === 0) {
return [];
}
const endIndices: number[] = [];
for (let endIndex = startIndex + 1; endIndex < cells.length - 1; ++endIndex) {
if (!cells[endIndex + 1].hasTile()) {
endIndices.push(endIndex);
}
}
endIndices.push(cells.length - 1);
return endIndices;
};