It was probably more luck than anything else. From several examples I noticed that the operation may create a result that's greater, in between or smaller than the operands. That made me thinking of some sort of binary nature of the operation (similar to binary OR, AND or XOR). So, for a while, I've been using the binary representation of the numbers trying unsuccessfuly to figure out the binary operation that would produce these results. That made me think that some other numerical system may be involved. So, I just decided to try the base 3 system. Once I converted the numbers to base 3 it became quite obvious what the operation does.