Hell everyone. I am a noob in programming still. Now I’m stuck at puzzle “Balanced ternary computer: encode”. Actually having trouble about understanding the task.
At first we have ternary numeral system, which is based on numbers (0, 1 and 2) and after some attempts I suppose this encoding table:
{ 2: ‘1’,
1: ‘T’,
0: ‘0’, }
Some algorithm of mine works with tests 3 and 4 but still fails with tests 1 and 2.

have now idea about encoding input 8 to expected “10T”. I have “11” on the output

the same dead end about input -15 and expected “T110”. And my output is “-T10”.
Can anybody explain the encoding algorithm for me please?
Thanks anyway.

Google should bring you to suitable wiki pages.
A quick calculation, base3’s value for 4 digits are 27, 9, 3, 1
so that 10T means 19 + 1-1 = 8
and also that T110 = 27*-1 + 91 + 31 = -15

Sorry, still missing the point of task.
How in two steps of

the result contains 3 symbols of

?
And back to text of task, about 6

And correct me, if I’m wrong: in basic ternary numerics are [0, 1, 2] and according to task it should become [T, 0, 1].
I got the first symbol for result string. Don’t want to spoil it here. And don’t know how to get the rest in correct order and quantity.

Perhaps starting with very basic examples first.
You asked why Decimal 8 equals “10T”.
Assume you know why there is a sequence 81, 27, 9, 3, 1. Here I only need [9, 3, 1].

“1” means 1 * 9
“0” means 0 * 3
“T” means T * 1 = -1 * 1
Sum the results, becomes 9-1 = 8.

Thanks for you answer but are you serious ? Test it in CodinGame, you’ll never see this error. 100% pass through the IDE but only 50% is validate. This would be impossible with this error, I think.

The IDE does not have all the cases as you’ll see. to try it i did a for loop from -100 to 100. Pass the value to your code and to mine. To fix the issue you just have to remove the first zero of your output !

I am stuck in this puzzle (coding it in C)! My code passes all tests but when I submit, there is one test I am not passing (the 3rd one). Is there a way to know what value is tested for test n°3 (I don’t what to hardcode the solution but just know what values are failing)? Or does anybody want to check my code to see and tell me what is wrong with it ?

Here is a screen of my methodology to solve this exercise. For a given number, i calculate its index in a range between sum_of_power(3i) and sum_of_power(3(i+1)). The index is equal to the number minus the sum of the power of 3 to the index i.

Once I have the index, for each power of 3 I calculate : (index%3i) / 3i.
I know that if this calculus gives me a number equals to 0 or greather than 2/3, then for this unit it is a “T” if n < 0 or a “1” if n > 0.
If this calculus give me a number inferior or equals to 1/3, then for this unit it is a “1” if n < 0 or a “T” if n > 0.
Else, this unit is equal to 0.
This is all summed up on my screen above.