PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: lavish_adm
Testers: utkarsh_adm, iceknight1093
Editorialist: hrishik85
DIFFICULTY:
366
PREREQUISITES:
None
PROBLEM:
Alice and Bob are playing air hockey. The first person to earn 7 points wins the match. We have to calculate the minimum number of points in which the match will end.
EXPLANATION:
Note that there is no constraint around the sequence in which the players score points. Any player can win.
Hint 1
How many points does Alice require to win the match? How many points does Bob require to win the match?
If Alice wins the next few points, she can win the match in (7 - A) points
If Bob wins the next few points, he can win the match in (7 - B) points
Hint 2
If both Bob and Alice score points, can the match end sooner?
No - it cannot! Since this will only increase the number of points which have to scored before the match ends
Hint 3
From the above, we can see that the minimum points required to win the match is Min[(7 - A), (7 - B)]
TIME COMPLEXITY:
Time complexity is O(1).
SOLUTION:
Editorialist's Solution
t=int(input())
for _ in range(t):
a,b=map(int,input().split())
print(min((7-a),(7-b)))