The members of the set of integers $A_n$ that total the natural number $n,$ where all members of the set are a power of three can be defined as
\begin{align}
A_n=\small{\left\{3^k \left(\left\lfloor 3^{-k} \left(2 n+3^{\left\lceil \log _3(2 n+1)\right\rceil }-1\right)\right/2\rfloor -3 \left\lfloor 3^{-k-1} \left(2 n+3^{\left\lceil \log _3(2 n+1)\right\rceil }-1\right)/2\right\rfloor -1\right)\\
~\Big{|}~ k\in \mathbb{Z} \land 0 \leq k \leq \left\lfloor \log _3\left(\left(3^{\left\lceil \log _3(2 n+1)\right\rceil }-1\right)/2+n\right)\right\rfloor\right\}}\\
\end{align}
Mathematica code:
a[n_] := DeleteCases[#, 0] &@ Table[3^k*(-1 - 3*Floor[(3^(-1 - k)*
(-1 + 3^Ceiling[Log[3, 1 + 2*n]] + 2*n))/2] +
Floor[(-1 + 3^Ceiling[Log[3, 1 + 2*n]] + 2*n)/(2*3^k)]),
{k, 0, Floor[Log[3, (-1 + 3^Ceiling[Log[3, 1 + 2*n]])/2 + n]]}]
Then a[#] &/@ Range @ 20
gives
{{1}, {-1, 3}, {3}, {1, 3}, {-1, -3, 9}, {-3, 9}, {1, -3, 9},
{-1, 9}, {9}, {1, 9}, {-1, 3, 9}, {3, 9}, {1, 3, 9}, {-1, -3, -9, 27},
{-3, -9, 27}, {1, -3, -9, 27}, {-1, -9, 27}, {-9, 27}, {1, -9, 27},
{-1, 3, -9, 27}}
Clearly the negative integers in $A_n$ should go on the same side as the weight, so
f[n_] := {{Total@#}, Select[#, # > 0 &], Join[{"W"},
-Select[#, # < 0 &]]} &@a@# &@n
Grid[f[#] & /@ Range@20, Alignment -> Left]
gives
1 {1} {W}
2 {3} {W, 1}
3 {3} {W}
4 {1, 3} {W}
5 {9} {W, 1, 3}
6 {9} {W, 3}
7 {1, 9} {W, 3}
8 {9} {W, 1}
9 {9} {W}
10 {1, 9} {W}
11 {3, 9} {W, 1}
12 {3, 9} {W}
13 {1, 3, 9} {W}
14 {27} {W, 1, 3, 9}
15 {27} {W, 3, 9}
16 {1, 27} {W, 3, 9}
17 {27} {W, 1, 9}
18 {27} {W, 9}
19 {1, 27} {W, 9}
20 {3, 27} {W, 1, 9}
and the first thousand values of $A_n$ are calculated in $\approx 0.5$ seconds on my (slow) machine.