TITLE: In how many ways can you colorize the vertices of a grid with 4 colors so that every unit-square vertices are all of a different color?
QUESTION [11 upvotes]: In how many ways can you colorize the vertices of an $(n\times n)$-square forming an $(n+1)$-grid with $4$ colors so that every unit-square vertices are all of a different color ?
Precisions:
$(n\times n)$-square: square whose edge length is $n$.
$(n+1)$-grid: square grid containing $(n+1)$ vertices per side, and composed of $n^2$ unit-squares of dimension $(1\times 1)$.
Here are some examples for $n=1,2,3$

My attempt:
I have posted a similar question here I tried to do the same way (Because the answer is like that too ($24\times (2^{n}-1)$)) but it didn't answer.
Any hints?

REPLY [3 votes]: I thought about this for a while and came to a conclusion:
No. of Ways to Colour = $4!*(2^n-1)$!
In the case of an nxn grid, you can consider it to be an $(n-1)$ by $(n-1)$ grid with $2n-1$ vertices wrapped around it. Next, imagine that the $n-1$ grid is already coloured.  Look at this photo:

Then, to colour the "layer" around it, we have 2 ways to colorize 
the vertices on the unit-box in the bottom righthand corner. Then, moving upwards, all the vertices up to the top-righthand corner are determined, since two of the colours have been defined by the $(n-1)$ grid and the bottom righthand corner of each box is chosen by the one below (ending at one of the 2 choices for the bottom righthand one). 

At the top righthand corner, we again meet 2 choices, since you have the top righthand vertex of the $(n-1)$ grid and another is coloured from the ones determined around the edge, and then the rest of the colours are determined. 

Thus, for an n-sized grid there are $4*(n-1)$ ways of colorizing the vertices satisfying the conditions above. However, if we look more carefully, we can find cases where only one of these 2 choices are given to us and that in fact, we only ever get one of these 2 choices. Consider the case where one of our 2 colours to "choose" from is also the colour of the vertex 2 up, 1 left from the bottom righthand corner. If this was true, we would only have one choice in how we arrange the colours, and that would be the same as the penultimate column of the $(n-1)$ box. 
If this was true, another consequence would be that you could still choose one of 2 configurations in the top righthand corner, since we know the reflected columns fact. However, if in the first case we had 2 choices then by the time we had got to the top righthand corner, we would not have 2 choices there, since the columns would not be reflected.
Thus, we must re-state our formula as $2*(n-1)$.
Now, for n = 1, the number of ways of colouring it such that the colours are different with 4 colours is simply $4! = 4*3*2*1 = 24$.
Thus, we derive the number of ways to colour an n by n grid using 4 colours such that every unit-square vertices are a different colour with 4 colours is $4!*(2^n-1)$.