%N a(n) is the numbers of ways to write 2*n = u + v where the ternary representations of u and of v have the same number of digits d for d = 0..2.
%C In other words, a(n) is the number of ways to write 2*n as the sum of two ternary anagrams.
%C Leading zeros are ignored.
%C Two ternary anagrams have necessarily the same parity, hence an odd number cannot be the sum of two ternary anagrams.
%H Rémy Sigrist, <a href="/A330827/b330827.txt">Table of n, a(n) for n = 0..19683</a>
%H Rémy Sigrist, <a href="/A330827/a330827.gp.txt">PARI program for A330827</a>
%H Rémy Sigrist, <a href="/A330827/a330827.png">Scatterplot of (x, y) such that 0 <= x, y <= 3^7 and x and y are ternary anagrams</a> (a(n) corresponds to the number of pixels (x, y) such that x+y = n)
%e For n = 6:
%e - we can write 12 as u + v in the following ways:
%e u v ter(u) ter(v)
%e - - ------ ------
%e 5 7 12 21
%e 6 6 20 20
%e 7 5 21 12
%e - hence a(6) = 3.
%o (PARI) See Links section.
%Y Cf. A331216 (binary analog), A331218 (decimal analog).
%A _Rémy Sigrist_, Jan 12 2020