trigrams are hard

There's a builtin that would help you convert integers to hexadecimal.