Codechef•Jun 15, 2025
Too many Floors
Hazrat Ali
Codechef
Chef and Chefina are residing in a hotel.
There are 1010 floors in the hotel and each floor consists of 1010 rooms.
- Floor 11 consists of room numbers 1 to 10.
- Floor 22 consists of room numbers 11 to 20
- Floor ii consists of room numbers 10⋅(i−1) to 10
You know that Chef's room number is X while Chefina's Room number is Y.
If Chef starts from his room, find the number of floors he needs to travel to reach Chefina's room.
Input Format
- First line will contain T, number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, two integers X,YX,Y, the room numbers of Chef and Chefina respectively.
Output Format
For each test case, output the number of floors Chef needs to travel to reach Chefina's room.
Constraints
- 1≤T≤1000
- 1≤X,Y≤100
- X≠Y
Sample 1:
Input
4 1 100 42 50 53 30 81 80
Output
9 0 3 1
Solution
import math
t = int(input())
for _ in range(t):
x, y = map(int, input().split())
high = math.ceil(x / 10)
low = math.ceil(y / 10)
floor = abs(low - high)
print(floor)