Let $A$, $B$, $C$ and $D$ be the vertices of a regular tetrahedron, each of whose edges measures $1$ meter. A bug, starting from vertex $A$, observes the following rule: at each vertex it chooses one of the three edges meeting at that vertex, each edge being equally likely to be chosen, and crawls along that edge to the vertex at its opposite end. Let $p = \frac{n}{729}$ be the probability that the bug is at vertex $A$ when it has crawled exactly $7$ meters. Find the value of $n$.
For all nonnegative integers $k,$ let $P(k)$ be the probability that the bug is at vertex $A$ when it has crawled exactly $k$ meters. We wish to find $p=P(7).$
Clearly, we have $P(0)=1.$ For all $k\geq1,$ note that after $k-1$ crawls:


The probability that the bug is at vertex $A$ is $P(k-1),$ and the probability that it crawls to vertex $A$ on the next move is $0.$
The probability that the bug is not at vertex $A$ is $1-P(k-1),$ and the probability that it crawls to vertex $A$ on the next move is $\frac13.$

Together, the recursive formula for $P(k)$ is
\[P(k) = \begin{cases} 1 & \mathrm{if} \ k=0 \\ \frac13(1-P(k-1)) & \mathrm{if} \ k\geq1 \end{cases}.\]
Two solutions follow from here:

Solution 1.1 (Recursive Formula)
We evaluate $P(7)$ recursively:
\begin{alignat*}{6} P(0)&=1, \\ P(1)&=\frac13(1-P(0))&&=0, \\ P(2)&=\frac13(1-P(1))&&=\frac13, \\ P(3)&=\frac13(1-P(2))&&=\frac29, \\ P(4)&=\frac13(1-P(3))&&=\frac{7}{27}, \\ P(5)&=\frac13(1-P(4))&&=\frac{20}{81}, \\ P(6)&=\frac13(1-P(5))&&=\frac{61}{243},\\ P(7)&=\frac13(1-P(6))&&=\frac{182}{729}. \end{alignat*}
Therefore, the answer is $n=\boxed{182}.$
~Azjps (Fundamental Logic)
~MRENTHUSIASM (Reconstruction)

Solution 1.2 (Explicit Formula)
Let $P(k)=Q(k)+c$ for some function $Q(k)$ and constant $c.$ For all $k\geq1,$ the recursive formula for $P(k)$ becomes \[Q(k)+c=\frac13(1-(Q(k-1)+c))=\frac13-\frac13Q(k-1)-\frac13c.\] Solving for $Q(k),$ we get \[Q(k)=\frac13-\frac13Q(k-1)-\frac43c.\]
For simplicity purposes, we set $c=\frac14,$ which gives \[Q(k)=-\frac13Q(k-1).\]
Clearly, $Q(0),Q(1),Q(2),\ldots$ is a geometric sequence with the common ratio $\frac{Q(k)}{Q(k-1)}=-\frac13.$ Substituting $P(0)=1$ and $c=\frac14$ into $P(0)=Q(0)+c$ produces $Q(0)=\frac34,$ the first term of the geometric sequence. 
For all nonnegative integers $k,$ the explicit formula for $Q(k)$ is \[Q(k)=\frac34\left(-\frac13\right)^k,\] and the explicit formula for $P(k)$ is \[P(k)=\frac34\left(-\frac13\right)^k+\frac14.\] Finally, the requested probability is $p=P(7)=\frac{182}{729},$ from which $n=\boxed{182}.$
~MRENTHUSIASM