*Applied Discrete Structures*, but could be given as a challenge to your students. The code implements the ideas of the proof, so it serves as a hint (or a solution?)

Several years ago, I had a WebMathematica page that computed the ternary representation of an integer. That page is no longer in existence, and I discovered that it several broken links to it were on sequence pages of The On-Line Encyclopedia of Integer Sequences, such as sequence A072998. As a replacement, I created a SageMath interact (similar to a Wolfram Demonstration).

The SageMath interact converts integers from 1 to 1000 to the ternary number system. It is contained within a Sage Cell, so anyone can view and tinker with the code. Any suggestions for improving it are welcome!