As others have mentioned, a common problem is understanding the meaning of the variables in the formula. [Which is primed? and unprimed? Maybe this notation is ambiguous.]
In my opinion, a spacetime diagram is good way to clarify the meaning of the different variables because one has something more tangible than "carefully-chosen but maybe not-well-understood strings of words or symbols". ("A spacetime diagram is worth a thousand words.")
The answer I offer here elaborates on the earlier answers by using the spacetime diagram, together with rapidities (Minkowski-angles),
which suggests helpful analogies with ordinary Euclidean trigonometry.
[In addition, given the Euclidean geometry version of this problem,
would one use rotation matrices?]

With time running upwards, we have drawn the worldlines of the earth, the asteroid [at rest with respect to the earth], and the ship that leaves the earth at event O and arrives at the asteroid at event Q.
With the ship velocity $v=(1/2)c$,
the gamma-factor is $\gamma=\frac{1}{\sqrt{1-v^2}}=\frac{2}{\sqrt{3}}=1.1547...$ [in units where $c=1$].
Using rapidities, where $v=\tanh\theta$, we have $\gamma=\cosh\theta$.
So, $\gamma=\cosh(\rm arctanh(v))=\cosh(\rm arctanh(0.5))=1.1547...$ (with help from WolframAlpha). The Rapidity-angle is angle between timelike worldlines of the earth and ship, and between their spacelike-directions in this plane.
Consider Minkowski-right-triangle OPQ (with hypotenuse $OQ$ and legs $PQ \perp OP$, along the earth's space and time axes). The velocity is $v=\frac{PQ}{OP}$.
Time-Dilation compares the measured-durations between events O and Q by comparing the (apparent-duration) timelike-leg OP to the (proper-time) timelike-hypotenuse OQ].
The time-dilation factor arises from $\gamma=\cosh\theta=\frac{ADJ}{HYP}=\frac{OP}{OQ}$.
So, $$(\mbox{apparent-duration } OP)=\gamma(\mbox{proper-time }OQ).$$
Consider Minkowski-right-triangle QPX (with hypotenuse $QX$ and legs $PX \perp QP$, along the earth's time and space axes).
Length-contraction compares the measured-distances between two parallel timelike-worldlines by comparing the (proper-length) spacelike-leg PQ to the (apparent-length) spacelike-hypotenuse XQ.
The length-contraction factor arises from $\gamma=\cosh\theta=\frac{ADJ}{HYP}=\frac{QP}{QX}$. So,
$$(\mbox{proper-length }QP)=\gamma(\mbox{apparent-length }QX),$$
or, more traditionally,
$$(\mbox{apparent-length }QX)=\frac{(\mbox{proper-length }QP)}{\gamma}.$$
With $v=(1/2)$ and $(PQ)=2$,
$$(QX)=\frac{(PQ)}{\gamma}=\frac{2}{\cosh({\rm{arctanh\ }0.5})}=\frac{2}{2/\sqrt{3}}=\sqrt{3}$$
$$(OP)=\frac{(PQ)}{v}=\frac{2}{1/2}=4$$
$$(OQ)=\frac{(OP)}{\gamma}=\frac{4}{2/\sqrt{3}}=2\sqrt{3},$$
in accord with the answers given earlier.
Refer to the diagram for a physical interpretation.