TITLE: We call a coloring of $3$-regular graph with $3$ colors good if for every $3$ edges incident with a vertex ...
QUESTION [18 upvotes]: Let $G$ be a $3$-regular graph with $n$ vertices. Color each edge with red, blue or yellow. Now, we call a coloring of graph as good if any three edges incident with any vertex have one color or three colors. Prove that the number of good coloring of  $G$ must be a power of $3$.

I have very short solution using linear algebra:
If $M$ is an incidence matrix of this graph and we color each edge with colors $0,1,2$ then we have to find a number of vectors $\vec{c}\in \mathbb{Z}_3^{\varepsilon}$ such that $M\vec{c} =\vec{0} \in \mathbb{Z}_3^{n}$ where $\varepsilon$ is a number of edges $G$. So we are interested in $|\ker(M)|$, but $\ker(M)\leq  \mathbb{Z}_3^{\varepsilon}$ and thus $|\ker(M)| = 3^{d}$ where $d=\dim (\ker(M))$.

 Even more, we can find exact number of colorings. By handshake lemma we have $\varepsilon = 3n/2$ so $n$ is even and by
 rank-nullity theorem we have $$ d=\varepsilon -{\rm rank} (M) $$ There is a theorem that says if $G$ is connected then:$${\rm rank}(M)=\cases{n-1;\;{\rm if\;}G\;{\rm is\;bipartite}\\ \;\;n\;\;\;\;;\;{\rm else}}$$  So $d={n\over 2}+1$ if $G$ is bipartite and $d={n\over 2}$ else. Clearly we can extend this results to all graphs, not just connected.

But I'm unable to get an elementary solution.

REPLY [7 votes]: Here is a solution that would/should be accepted in the condition of a Romanian Olympiad problem for 18yo college students. It does not use vector spaces (over a finite field), and the existence of a basis or alternaively the definition of the dimension (and the fact that dimension is well defined). But it uses some concepts related to finite groups and subgroups, mainly a result of Lagrange for finite - even abelian - groups. The proof of this result is related only to building an equivalence relation. This being said, i think the following lines can be guessed already...

Let $1,2,\dots,e$ build the index set $E$ of edges of the graph.
We use the colors $0,1,2$ which are the elements of the field $F=\Bbb F_3=\Bbb Z/3$ with three elements.
Let $G=F^E$ be the group of all tuples $a=(a(1), a(2),\dots, a(e))$ with entries in $F$, one may think equivalently of functions $a$ from the index set $E$ to the field $F$. Addition is done on components. Let $H$ be the subset (soon recognized as a subgroup) of all $a\in G$ such that for all vertices $i$ of the given graph, denoting by $\varepsilon_1,\varepsilon_2,\varepsilon_3$ the three different edges from $i$ we have in $F$
$$ a(\varepsilon_1)+a(\varepsilon_2)+a(\varepsilon_3)=0\ .
$$
Elements in $H$ correspond to good colorings, since the solutions of $x+y+z=0$ for $x,y,z$ in $F$ are exactly those with either $x=y=z$ or $\{x,y,z\} =\{0,1,2\}$.
One can easily check that $0=(0,0,\dots,0)$ is in $H$, that $H$ is closed w.r.t. to taking sum and difference, so $H$ is a subgroup of $G$. By Lagrange's Theorem, the cardinality of $H$ divides the cardinality of $G$ - which is $3^e$.
$\square$