When I see a problem like "Write a grammar for a language $L$ if $L = \{..\}$" for me is a matter of "instinct" the way that one can define productions. For example given the following exercise:
Let $L$ a language which alphabet is $\{x,y,z\}$ and accepts strings $w$ where there aren't consecutive $x$'s nor consecutive $y$'s nor consecutive $z$'s.
My first aproaching was to stablish that $x$, $y$ and $z$ each one are in $L$, that is:
$$S \rightarrow x \mid y \mid z$$
If the string has an $x$, there can be a consecutive $y$ or $z$, similarly for the other symbols. I assume that there are productions $A$, $B$ and $C$ that make the work, so the start production is:
$$S \rightarrow xA\mid yB\mid zC\mid x\mid y\mid z$$
Therefore $S$ can be splitted to define $A$, $B$ and $C$:
$\begin{eqnarray*}S &\rightarrow& A \mid B \mid C \\A &\rightarrow& yB \mid zC \mid y \mid z \\ B &\rightarrow& xA \mid zC \mid x \mid z\\ C &\rightarrow& xA \mid yB \mid x \mid y \end{eqnarray*}$
But as you all can see this is just my version, I started with base strings accepted by $L$ and then I followed my own thought of how to build the grammar. Is there a easy way to do this? or some advice for similar languages? (like those which have different number of symbols).