Problem:
A typical American-style crossword puzzle grid is an N x N matrix with black and white squares, which obeys the following rules:
* Every white square must be part of an "across" word and a "down" word.
* No word can be fewer than three letters long.
* Every white square must be reachable from every other white square.
The grid is rotationally symmetric (for example, the colors of the top left and bottom right squares must match). Write a program to determine whether a given matrix qualifies as a crossword grid.
- Generate a set (hash-list) of white square positions
- Select a white square and run BFS/DFS for all adjoining white square and remove the visited square positions from the white square position set.
- If the set is non-empty after visiting all the adjoining white squares, the crossword is invalid.
# NOTE: this is a PSEUDO-CODE
n = number of rows
m = number of columns
for i in range(0, n / 2):
for j in range(0, m / 2):
if grid[i][j] != grid[n - 1 - i][m - 1 - j]:
return False
return True
The question is vague without example