You have 3 different colors to paint the squares of a 3x3 grid.

-The total number of squares to be painted is 5.
-Each painted square must be adjacent (horizontally or vertically) to another painted square.
-Adjacent squares (horizontally or vertically) should be painted in different colors.

How many different ways can this task be done?

Notes:

-All three colors must be used.
-Disconnected groups of connected squares are allowed.

If the problem was asked for 2x2 grid and 2 different colors, and the number of squares to paint was 3, the answer would be 8.

[ You need to be a member of this site before you can submit an answer ]