Post History
Inspired by this Rosetta Code article. Introduction Balanced Ternary is a method of representing integers using -1, 0 and 1 in base 3. Decimal 11 = (1 * 32) + (1 * 31) + (−1 * 30) = [1,1,-1] or ...
#1: Initial revision
When The Ternary Is Balance
Inspired by [this Rosetta Code article.](http://rosettacode.org/wiki/Balanced_ternary) # Introduction Balanced Ternary is a method of representing integers using -1, 0 and 1 in base 3. Decimal 11 = (1 * 3<sup>2</sup>) + (1 * 3<sup>1</sup>) + (−1 * 3<sup>0</sup>) = [1,1,-1] or "++-" Decimal 6 = (1 * 3<sup>2</sup>) + (−1 * 3<sup>1</sup>) + (0 * 3<sup>0</sup>) = [1,-1,0] or "+-0" # Task Given any integer, you must give its balanced ternary representation in any permitted format (array, string, etc.) Your program must support all integers present within its maximum integer limit. # Test Cases [Reference implementation with first 200 values](https://tio.run/##lVRNb6MwED23v2I28ioGYwtabaUNTYR62/P2sGqVA6Qm8YoEhOmW9OO3p2MbKP3IYXNw7PGbmfeebSpZFxeHw6pItYara3g6BfxtUg2JWJUyz@NTsKHtHr6vyrOsgTlMeTSF@QL/pwFMQzcPzbyLs2k8JGXN2arEJJct1O6frJuh6n3RKNjKZlPewU4@AP3d1EC0h0ROtCxykRVSa2qpmNKu3BPRIi9UhRS32Yvnmr0cqfhr1wBR8LCRtTSTxRzCo/VXaV3vESWyVEt67tkOopZIWsv/bHQ57oMIyonycLIeyrhCroQRThHfGfWUfLOkXsTfUu2s2r6xw5tuFn/LltCB4cYHGgXnwU8hhO@9tXjPdW0T34jN4IN@u@Fif3zgUU/Y1NP3WYeifnKn1qrRoDRWqPZed32KsqyAbo2PePBh7MzowGbFmO3/sFGF7OO3RC0RxSOUNA6xOZzHowiLlpzHSOaL9AVE8CGdf05nLO6sdGOFbHsl72pCukO7ymZI93m0dF70Yqwlzt6qlrlqZ5d8ARRfEmnN4ZDWHDi8odTOglgPCsyrI4N1aBolWUBSD53TZd0A891JBLiBaIQ6BlfXXx4dJWl3cjcMnknWJz/TENoWhl0O/Z7njVV0/PhnfrgAhtOvBfnHBSUtakEj@u9JF92b6P5j9NHcGMM0aVmy76@e2dFpLt0qL2tTFDmS9s5cJJuFg5FMsTBeWtzxBtXJI0@Mbye2iKju9WaGQaE3Km/Gj/qIqTYtwIzOKbzZKXbs0RPG@SS24WwU5j8uQhddvQcz1sOtMyngqzWp3CCR5qkRSHkUhkLg4FmlCoWalGZbjaoR5ejr1Ly2YAKTwCAEfk2Q6@HwCg "Perl 6 – Try It Online") ``` 5 +-- 6 +-0 11 ++- 65 +-++- -44 -++0+ -540 -+-+000 ``` # Scoring This is code-golf. Shortest answer in each language wins.