Hi everybody,
Everyone knows how to convert number from decimal system to binary. I also do. Everyone also knows how to convert from decimal to the base of three system.
However, I have a problem where I need to convert decimal number to a "strange base 3" system where one symbol cannot be the first one and should be surrounded by the remaining two. So, one symbol cannot be repeated before one of the other two has been used.
So, if "0" is the symbol that cannot be the first one and that cannot repeat:
perfectly legit numbers: 120, 110202, 1020
numbers that should not exist: 01212(zero should not be in the front), 120012 (zeros cannot repeat)
Can somebody, please, help to come up with an algorithm that converts from decimal system to this "strange base 3" system and back.
Thank you in advance