You are given a 4x4 grid with 16 cells. Each cell can have
one out of four colors. How many combinations are possible
if directly vertical and horizontal neighbored cells must
not have the same color?
Correct answer: 6000732
Explanation:
There are five patterns an individual row may have: abab, abca, abcb,
abac, abcd. There are 12 of the first kind, 24 of each of the others.
We form a matrix a_ij of the number of type j that can legally be
adjacent to one of type i, and use this matrix as follows to produce
the answer: