Solution #
It’s kinda obvious that we need to write a function which solves the problem and the answer will be .
One tricky way to write is that we can get the required number by appending the first digit to the end of an arbitrary number. If x is less than 10, the answer is x, otherwise the answer is x without last digit (divide x by 10) plus 9. What’s more, if the last digit is smaller than the first digit we have to decrease the answer by 1.