scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
14 lines (11 loc) • 333 B
text/typescript
import { Point } from 'types';
export const getPositionInGrid = <T>(grid: T[][], constraint: (value: T) => boolean): Point | undefined => {
for (let y = 0; y < grid.length; ++y) {
for (let x = 0; x < grid[0].length; ++x) {
if (constraint(grid[y][x])) {
return { x, y };
}
}
}
return undefined;
};