Convert integer to balanced dozenal 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 &amp; -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) =&gt; [1,6,-1]
f(216) =&gt; [2,-6,0]
f(-82) =&gt; [-1,5,2]
f(0)   =&gt; [0]


Winner is the shortest, with upvotes being the tiebreaker.
J, 74 72 characters

Here's my J implementation (f =. not included in character count):

f =. **}.^:(*@#*0={.)@([:((12-~[),0&gt;:@{.@]`[`]}])`,@.(6&gt;[)/&amp;.|.0,12&amp;#.^:_1)@|


And some tests (each result is boxed, and underscore means negative):

   NB. Integers [-10..10]:
   (&lt;@f"0)i:10
┌────┬────┬────┬────┬────┬──┬──┬──┬──┬──┬─┬─┬─┬─┬─┬─┬────┬────┬────┬────┬────┐
│_1 2│_1 3│_1 4│_1 5│_1 6│_5│_4│_3│_2│_1│0│1│2│3│4│5│1 _6│1 _5│1 _4│1 _3│1 _2│
└────┴────┴────┴────┴────┴──┴──┴──┴──┴──┴─┴─┴─┴─┴─┴─┴────┴────┴────┴────┴────┘
   NB. Some boundary values:
   (&lt;@f"0)215 216 217 71 72 73 
┌──────┬──────┬──────┬────┬──────┬──────┐
│1 6 _1│2 _6 0│2 _6 1│6 _1│1 _6 0│1 _6 1│
└──────┴──────┴──────┴────┴──────┴──────┘


Interestingly, the rules for 6 have no special place in the function. They work that way just by handling all digits >= 6 together and only working on positive numbers.

I made another version, which doesn't rely on #.^:_1, but it's longer:

**_2&amp;([:}.^:(0={.)+/\)@(((&lt;.@%&amp;12,(1,-&amp;12)`(0,])@.(6&gt;])@(12&amp;|))@{.,}.)^:(0~:{.)^:_)@(,&amp;0)@|