## triumphost 120

How can I figure out where words intersect in the following?

``````AAAA#BBBB
.#.##C##H
.#.##D##I
.#...E.#J
##.##F##K
###..G..L
``````

'#' represents the black spots in a crossword where you cannot fill in.
'.' represents the spots with missing letters that need to be filled in.

I've read the puzzle into a

``````vector<string> Horizontal;
vector<string> Vertical;
``````

I can merge it or read it into a 2D array of strings as well but I cannot figure out where words intersect :S
I've got a list of all possible words that can fit into the spots given the letters that are currently there but I need a way to figure out where words intersect and where they don't so I can start filling it in.

Any ideas??

## deceptikon 1,790

If you have two non-black spots going in different directions from a cell, then that's an intersection:

``````bool is_intersection(char board[M][N], int x, int y)
{
if (board[x][y] == '#')
return false;

return
(board[x - 1][y] != '#' || board[x + 1][y] != '#') &&
(board[x][y - 1] != '#' || board[x][y + 1] != '#');
}
``````

## triumphost 120

Hmm that crashes on the very last row if there is a dot.

Example, in the puzzle on the first post: `###..G..L` When it encounters a dot, it will throw an error. Other than that, that works fine.

## deceptikon 1,790

Hmm that crashes on the very last row if there is a dot.

My example was just that, an example. It's your job to make sure that the concept is properly incorporated into your code, which includes adding error handling. It's pretty obvious that boundary cases aren't covered, and in hindsight I should have added a comment for those who fail to engage their brains before copying and pasting. For example, if you say `board[x - 1]` and `x` is 0, what do you think will happen?