Create a function which takes an integer and returns an array of integers representing the number in balanced base twelve. Specifically, the representation should follow these rules regarding 6 & -6 (from the above link):
- If the last digit of a number could be written with either 6 or ϑ, we use the one whose sign is opposite the sign of the first digit. For example, we write decimal 30 as dozenal 3ϑ, but decimal -30 as as dozenal ε6, not ζϑ.
- If a 6 or ϑ occurs before the last digit of a number, we use the one whose sign is opposite the next digit after it. For example, we write decimal 71 as dozenal 6τ, but decimal 73 as as dozenal 1ϑ1, not 61.
- If a 6 or ϑ is followed by a 0, we keep looking to the right until we can apply one of the first two rules. For example, we write decimal -72 as dozenal τ60, not ϑ0.
Otherwise, the only restrictions are to use only digits in [-6..6], and for the output, when interpreted as big-endian base twelve, to be equivalent to the input.
Example of use:
f(215) => [1,6,-1]
f(216) => [2,-6,0]
f(-82) => [-1,5,2]
f(0) => [0]
Winner is the shortest, with upvotes being the tiebreaker.