Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Alice is playing Air Hockey with Bob. The first person to earn seven points wins the match. Currently, Alice’s score is A and Bob’s score is B.
Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends.
For each test case, output on a new line the minimum number of points that will be further scored in the match before it ends.
Input: 4
0 0
2 5
5 2
4 3
Output: 7
2
2
3
Test case 1: The current score is 0−0. If either Alice or Bob scores 7 consecutive points, then the score will become 7−0 or 0−7 respectively, and the game will end. It can be proven that at least 7 points will be further scored in the match before it ends.
Test case 2: The current score is 2−5. If Bob scores 2 consecutive points, then the score will become 2−7 and the game will end. It can be proven that at least 2 points will be further scored in the match before it ends.
Test case 3: The current score is 5−2. If Alice scores 2 consecutive points, then the score will become 7−2 and the game will end. It can be proven that at least 2 points will be further scored in the match before it ends.
Test case 4: The current score is 4−3. If Alice scores 3 consecutive points, then the score will become 7−3 and the game will end. It can be proven that at least 3 points will be further scored in the match before it ends.
t =int(input())
for i in range(t):
a,b=map(int,input().split())
if a>b:
print(7-a)
elif b>=a:
print(7-b)
#include <iostream>
using namespace std;
int main() {
int T;
cin>>T;
while(T--)
{
int A,B;
cin>>A>>B;
if(A>B)
cout<<7-A<<"\n";
else
cout<<7-B<<"\n";
}
return 0;
}
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner (System.in);
int t=sc.nextInt();
while(t-->0){
int a=sc.nextInt();
int b=sc.nextInt();
if(a>=b)
System.out.println(7-a);
else
System.out.println(7-b);
}
}
}
In our experience, we suggest you solve this Air Hockey CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Air Hockey CodeChef Solution
I hope this Air Hockey CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>