Your task is to count how many numbers in the range consist of the digits and only. For example, in the range the numbers are , , , , and , and thus the answer is .
In a file twodigit.py
, implement the function count_numbers
that counts the desired numbers in the range. The function is given the parameters and representing the end points of the range.
Your function will be tested using many different ranges. In each test, .
You must implement the function efficiently so that the solution is returned quickly even for long ranges.
def count_numbers(a, b): # TODO if __name__ == "__main__": print(count_numbers(1, 100)) # 6 print(count_numbers(60, 70)) # 0 print(count_numbers(25, 25)) # 1 print(count_numbers(1, 10**9)) # 1022 print(count_numbers(123456789, 987654321)) # 512