Let $$E$$ denote the condition that the number of $$X$$'s is even, and $$O$$
denote the condition that the number of $$Y$$'s is odd.
Each of the $$7$$ positions can be filled with $$X,Y,Z$$
so the total number of strings is $$3^7$$
We use the parity filter.
The required count is
$$N=\frac14\sum_{x=\pm1}\sum_{y=\pm1}(1+x)(1-y)(x+y+1)^7$$
Evaluating the four cases:
For
$$x=1,\ y=1$$
$$(1+x)(1-y)(x+y+1)^7=0$$
For
$$x=1,\ y=-1$$
$$(1+x)(1-y)(x+y+1)^7$$
$$=(2)(2)(1)^7$$
$$=4$$
For
$$x=-1,\ y=1$$
the contribution is $$0$$
For
$$x=-1,\ y=-1$$
the contribution is $$0$$
Hence
$$N=\frac14\left(3^7+1\right)$$
$$=\frac14(2187+1)$$
$$=\frac{2188}{4}$$
$$=547$$
Therefore the number of passcodes is
$$547$$
Final Answer :
$$547$$