Problem: How many ways are there to place $3$ indistinguishable red chips, $3$ indistinguishable blue chips, and $3$ indistinguishable green chips in the squares of a $3 \times 3$ grid so that no two chips of the same color are directly adjacent to each other, either vertically or horizontally?
$\textbf{(A)} ~12\qquad\textbf{(B)} ~18\qquad\textbf{(C)} ~24\qquad\textbf{(D)} ~30\qquad\textbf{(E)} ~36$

Solution: Without the loss of generality, we fix the top-left square with a red chip. We apply casework to its two adjacent chips:
Case (1): The top-center and center-left chips have different colors. [asy] /* Made by MRENTHUSIASM */ unitsize(7mm); fill((6,2)--(7,2)--(7,3)--(6,3)--cycle, red); fill((7,2)--(8,2)--(8,3)--(7,3)--cycle, blue); fill((6,1)--(7,1)--(7,2)--(6,2)--cycle, green); fill((7,1)--(8,1)--(8,2)--(7,2)--cycle, red); draw((6,0)--(9,0)--(9,3)--(6,3)--cycle, linewidth(1.5)); draw((6,1)--(9,1), linewidth(1.5)); draw((6,2)--(9,2), linewidth(1.5)); draw((7,0)--(7,3), linewidth(1.5)); draw((8,0)--(8,3), linewidth(1.5)); [/asy] There are three subcases for Case (1): [asy] /* Made by MRENTHUSIASM */ unitsize(7mm); fill((0,2)--(1,2)--(1,3)--(0,3)--cycle, red); fill((1,2)--(2,2)--(2,3)--(1,3)--cycle, blue); fill((0,1)--(1,1)--(1,2)--(0,2)--cycle, green); fill((1,1)--(2,1)--(2,2)--(1,2)--cycle, red); fill((2,2)--(3,2)--(3,3)--(2,3)--cycle, red); fill((2,1)--(3,1)--(3,2)--(2,2)--cycle, green); fill((2,0)--(3,0)--(3,1)--(2,1)--cycle, blue); fill((0,0)--(1,0)--(1,1)--(0,1)--cycle, blue); fill((1,0)--(2,0)--(2,1)--(1,1)--cycle, green);  fill((6,2)--(7,2)--(7,3)--(6,3)--cycle, red); fill((7,2)--(8,2)--(8,3)--(7,3)--cycle, blue); fill((6,1)--(7,1)--(7,2)--(6,2)--cycle, green); fill((7,1)--(8,1)--(8,2)--(7,2)--cycle, red); fill((8,2)--(9,2)--(9,3)--(8,3)--cycle, green); fill((8,1)--(9,1)--(9,2)--(8,2)--cycle, blue); fill((8,0)--(9,0)--(9,1)--(8,1)--cycle, green); fill((6,0)--(7,0)--(7,1)--(6,1)--cycle, red); fill((7,0)--(8,0)--(8,1)--(7,1)--cycle, blue);  fill((12,2)--(13,2)--(13,3)--(12,3)--cycle, red); fill((13,2)--(14,2)--(14,3)--(13,3)--cycle, blue); fill((12,1)--(13,1)--(13,2)--(12,2)--cycle, green); fill((13,1)--(14,1)--(14,2)--(13,2)--cycle, red); fill((14,2)--(15,2)--(15,3)--(14,3)--cycle, green); fill((14,1)--(15,1)--(15,2)--(14,2)--cycle, blue); fill((14,0)--(15,0)--(15,1)--(14,1)--cycle, red); fill((12,0)--(13,0)--(13,1)--(12,1)--cycle, blue); fill((13,0)--(14,0)--(14,1)--(13,1)--cycle, green);  draw((0,0)--(3,0)--(3,3)--(0,3)--cycle, linewidth(1.5)); draw((0,1)--(3,1), linewidth(1.5)); draw((0,2)--(3,2), linewidth(1.5)); draw((1,0)--(1,3), linewidth(1.5)); draw((2,0)--(2,3), linewidth(1.5));  draw((6,0)--(9,0)--(9,3)--(6,3)--cycle, linewidth(1.5)); draw((6,1)--(9,1), linewidth(1.5)); draw((6,2)--(9,2), linewidth(1.5)); draw((7,0)--(7,3), linewidth(1.5)); draw((8,0)--(8,3), linewidth(1.5));  draw((12,0)--(15,0)--(15,3)--(12,3)--cycle, linewidth(1.5)); draw((12,1)--(15,1), linewidth(1.5)); draw((12,2)--(15,2), linewidth(1.5)); draw((13,0)--(13,3), linewidth(1.5)); draw((14,0)--(14,3), linewidth(1.5)); [/asy] As there are $3!=6$ permutations of the three colors, each subcase has $6$ ways. So, Case (1) has $3\cdot6=18$ ways in total.
Case (2): The top-center and center-left chips have the same color. [asy] /* Made by MRENTHUSIASM */ unitsize(7mm); fill((6,2)--(7,2)--(7,3)--(6,3)--cycle, red); fill((7,2)--(8,2)--(8,3)--(7,3)--cycle, blue); fill((6,1)--(7,1)--(7,2)--(6,2)--cycle, blue); draw((6,0)--(9,0)--(9,3)--(6,3)--cycle, linewidth(1.5)); draw((6,1)--(9,1), linewidth(1.5)); draw((6,2)--(9,2), linewidth(1.5)); draw((7,0)--(7,3), linewidth(1.5)); draw((8,0)--(8,3), linewidth(1.5)); [/asy] There are three subcases for Case (2): [asy] /* Made by MRENTHUSIASM */ unitsize(7mm); fill((0,2)--(1,2)--(1,3)--(0,3)--cycle, red); fill((1,2)--(2,2)--(2,3)--(1,3)--cycle, blue); fill((0,1)--(1,1)--(1,2)--(0,2)--cycle, blue); fill((1,1)--(2,1)--(2,2)--(1,2)--cycle, green); fill((2,2)--(3,2)--(3,3)--(2,3)--cycle, red); fill((2,1)--(3,1)--(3,2)--(2,2)--cycle, blue); fill((2,0)--(3,0)--(3,1)--(2,1)--cycle, green); fill((0,0)--(1,0)--(1,1)--(0,1)--cycle, green); fill((1,0)--(2,0)--(2,1)--(1,1)--cycle, red);  fill((6,2)--(7,2)--(7,3)--(6,3)--cycle, red); fill((7,2)--(8,2)--(8,3)--(7,3)--cycle, blue); fill((6,1)--(7,1)--(7,2)--(6,2)--cycle, blue); fill((7,1)--(8,1)--(8,2)--(7,2)--cycle, green); fill((8,2)--(9,2)--(9,3)--(8,3)--cycle, green); fill((8,1)--(9,1)--(9,2)--(8,2)--cycle, red); fill((8,0)--(9,0)--(9,1)--(8,1)--cycle, green); fill((6,0)--(7,0)--(7,1)--(6,1)--cycle, red); fill((7,0)--(8,0)--(8,1)--(7,1)--cycle, blue);  fill((12,2)--(13,2)--(13,3)--(12,3)--cycle, red); fill((13,2)--(14,2)--(14,3)--(13,3)--cycle, blue); fill((12,1)--(13,1)--(13,2)--(12,2)--cycle, blue); fill((13,1)--(14,1)--(14,2)--(13,2)--cycle, green); fill((14,2)--(15,2)--(15,3)--(14,3)--cycle, green); fill((14,1)--(15,1)--(15,2)--(14,2)--cycle, red); fill((14,0)--(15,0)--(15,1)--(14,1)--cycle, blue); fill((12,0)--(13,0)--(13,1)--(12,1)--cycle, green); fill((13,0)--(14,0)--(14,1)--(13,1)--cycle, red);  draw((0,0)--(3,0)--(3,3)--(0,3)--cycle, linewidth(1.5)); draw((0,1)--(3,1), linewidth(1.5)); draw((0,2)--(3,2), linewidth(1.5)); draw((1,0)--(1,3), linewidth(1.5)); draw((2,0)--(2,3), linewidth(1.5));  draw((6,0)--(9,0)--(9,3)--(6,3)--cycle, linewidth(1.5)); draw((6,1)--(9,1), linewidth(1.5)); draw((6,2)--(9,2), linewidth(1.5)); draw((7,0)--(7,3), linewidth(1.5)); draw((8,0)--(8,3), linewidth(1.5));  draw((12,0)--(15,0)--(15,3)--(12,3)--cycle, linewidth(1.5)); draw((12,1)--(15,1), linewidth(1.5)); draw((12,2)--(15,2), linewidth(1.5)); draw((13,0)--(13,3), linewidth(1.5)); draw((14,0)--(14,3), linewidth(1.5)); [/asy] As there are $3!=6$ permutations of the three colors, each subcase has $6$ ways. So, Case (2) has $3\cdot6=18$ ways in total.
Answer
Together, the answer is $18+18=\boxed{36}.$

Answer: E 36