Place one of A, B, C or D into each of the 25 empty squares so that the number of letters in each row and column match the number indicated on that row and column for that letter.

Identical letters cannot be next to each other vertically or horizontally, but may be adjacent diagonally.

+---+---+---+---+---+
A | 2 | 1 | 2 | 1 | 0 |
+---+---+---+---+---+
B | 0 | 2 | 0 | 2 | 2 |
+---+---+---+---+---+
C | 1 | 0 | 2 | 2 | 2 |
+---+---+---+---+---+
A B C D | 2 | 2 | 1 | 0 | 1 |
+---+---+---+---++===+===+===+===+===+
| 1 | 2 | 2 | 0 || | | | | |
+---+---+---+---++---+---+---+---+---+
| 1 | 1 | 2 | 1 || | | | | |
+---+---+---+---++---+---+---+---+---+
| 1 | 2 | 0 | 2 || | | | | |
+---+---+---+---++---+---+---+---+---+
| 2 | 0 | 1 | 2 || | | | | |
+---+---+---+---++---+---+---+---+---+
| 1 | 1 | 2 | 1 || | | | | |
+---+---+---+---++---+---+---+---+---+

From Mensa Puzzle Calendar 2019 by Fraser Simpson, Workman Publishing, New York. Puzzle for September 5.

rabbit-3:~ lord$ g77 -o walk walk.f

rabbit-3:~ lord$ walk

Success!

C B A C B

A D C B C

D B D A B

A D A C D

D A C B C

*This seemed hard, but finally was not. 1st I **systematically **tried **possibilities (like trying combinations of B's in one row and A's in another). But the bookkeeping became too much. Then I tried pre-setting cells at the intersection of 2 in one row and 2 in one col by giving the cell that letter, and then I played around with the rest. This proved futile. Then I wrote a ***program** that started with an A in the first square, and then a B in the second, etc., backing-up if ABCD was run through unsuccessfully. I.e, checking against the constraints in any square and backing-up positionally and advancing the symbol in the previous cell. (This algorithm has a name I forget.) This solved it, but then looking through what the program had done, I realized this method would have gone quickly even if done by hand! (I think having no "D"s in the top line helped it succeed quickly.)

*Edited on ***September 15, 2019, 6:58 pm**