# Untitled

unknown
python
a year ago
1.4 kB
1
Indexable
Never
```def count_digits_between(A, B):
digits_count = [0] * 10  # Initialize list with zeros for each digit
for num in range(A, B+1):
str_num = str(num)
for digit in str_num:
digits_count[int(digit)] += 1
return digits_count

def test():
num_test = int(input())
for i in range(num_test):
[a, b]  = [int(num) for num in   input().split(" ")]
result = count_digits_between(a, b)
print(result)

# def count_digits_between(A, B):
#     # Calculate the frequency of each digit in B
#     digits_count = [0] * 10
#     str_B = str(B)
#     for i, digit in enumerate(str_B):
#         digit_value = int(digit)
#         digits_count[digit_value] += int(str_B[:i] or '0') * (10 ** (len(str_B)-i-1))
#         digits_count[digit_value] += (A % (10 ** (len(str_B)-i-1))) + (B - B % (10 ** (len(str_B)-i-1)) - A + (A % (10 ** (len(str_B)-i-1))) - 1) * (digit_value > 0)

#     # Calculate the frequency of each digit in A-1
#     if A > 0:
#         str_A = str(A-1)
#         for i, digit in enumerate(str_A):
#             digit_value = int(digit)
#             digits_count[digit_value] -= int(str_A[:i] or '0') * (10 ** (len(str_A)-i-1))
#             digits_count[digit_value] -= (A-1) % (10 ** (len(str_A)-i-1)) * (digit_value > 0)

#     return digits_count

if __name__=='__main__':
test()```