## A's and B's

Find all 5-letter words consisting solely of the letters A and B, such that there are no words with three repeated characters in a row (no AAAxx, xAAAx, or xxAAA words.) There are 16 such words. Make a 5x5 grid of A's and B's, such that each row (read left to right), column (read top to bottom), and the two diagonals (read top to bottom) is a different one of these words. Follow-up: how many such squares are there? Is it possible to make a square in which all the words beginning with "A" can be found?

Source: Original. Based upon Macalester College Problem of the Week #965, which asked the 4-letter version of this problem, of which there is a single solution.

Solutions were received from Denis Borris and Al Zimmermann. Al's solution follows:
```There are 20 solutions.  Here are 10 of them.  The other 10 can be
obtained by swapping the A's for B's and vice-versa.  Only the first
solution below contains all 8 allowable words beginning with A.

A A B A A     A A B B A     A A B B A     A B A B A     A B A B A
B B A B A     B A A B B     B B A B B     B A A B B     B A B A A
B B A A B     A B B A A     A A B A A     A B B A A     A B B A B
A A B B A     B A B A B     B A B A B     B A B A A     B A A B A
B A B A B     B B A B A     B B A B A     B B A B B     B B A B A

A B A B B     A B A B B     A B A B B     A B A B B     A B B A B
A B A A B     B A B A B     B A B A B     B A B A B     A B B A A
B A B B A     A A B A A     A A B B A     A A B B A     B A A B B
A A B A B     B B A B B     B B A A B     B B A A B     A B A B A
A B A B A     A B B A A     A B A A B     A B B A A     A A B A B
```

Mail to Ken