You can first take off the last digit with %10, then /= 10 the number, until only a digit left. That way, you can get the edge tickets. (Can you infer from this explanation how to do the final step?)
What do you have to do in order to make two digits become an actual multidigit number? How can 1 and 2 become 12? Look at the procedure I described. It is related to that.