How can I define a function to show that $\{3^n\mid n\in\mathbb{Z}\}$ is countably infinite? I have to answer the following question for an assignment:

Is the set $A=\{3^{n}\mid n\in\mathbb{Z}\}$ finite, countably infinite, or uncountable?

I've defined what I originally thought to be a proper function rule showing a bijection from $\mathbb{N}$ to $A$, but I've since realized that I'm missing some elements in the codomain.
\begin{equation*}
  f:\mathbb{N}\to A:\left\{
    \begin{array}{ll}
      n\mapsto 3^{n},&\text{if $n=2k-1$ for some $k\in\mathbb{N}$}\\
      n\mapsto 3^{-n},&\text{if $n=2k$ for some $k\in\mathbb{N}$}
    \end{array}\right.
\end{equation*}
Here, I noticed that I'm missing all the odd negative numbers and all the even positive numbers.
Is this even doable this way, or do I need to draw a diagram? 
I'd much prefer to have a function definition if possible.

For every $n \in \mathbb Z$, there exists a unique $f(n) \in A$ as defined. That is, and for every number of the form $3^n$, there exists unique $n \in \mathbb Z$ such that $f(n) = 3^n$
The function is a bijection: one-to-one and onto. Hence there is a one-to-one correspondence between $A$ and 
$f(n) = 3^n, \;\;\forall n \in \mathbb Z$
Therefore: $\quad|A| = |\mathbb Z|$
We know $\mathbb Z$ is countably infinite, hence so must be $A$. 

We can also work to find a bijection between $A$ and $\mathbb{N}$, by adjusting your attempt just a bit:
You're definition, with a few adjustments, will work nicely for defining a bijection from $\mathbb{N}$ to $A$.
Consider
$$f:\mathbb{N}\to A:
\begin{cases} {n\to 3^{\Large\frac{(n-1)}{2}}};& n=2k-1,& k\in\mathbb{N} \\ \\
{ n\to 3^{\Large-\frac{n}{2}}}; & n=2k,& k\in\mathbb{N} \\ \\  
\end{cases}
$$
Therefore $|A| = |\mathbb N|$ which means since $\mathbb N$ is countably infinite, so must be set $A$.$\quad\square$
