Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Air Hockey CodeChef Solution

Problem – Air Hockey CodeChef Solution

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.

Input Format

  • The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains two space-separated integers A and B, as described in the problem statement.

Output Format

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.

Constraints

  • 1≤T≤50
  • 0≤A,B≤6

Sample 1:

Input: 4
0 0
2 5
5 2
4 3
Output: 7
2
2
3

Explanation:

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.

Air Hockey CodeChef Solution in Pyth 3

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)
    
    

Air Hockey CodeChef Solution in C++14

#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;
}

Air Hockey CodeChef Solution in Java

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);
}
	}
}
Air Hockey CodeChef Solution Review:

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

Find on CodeChef

Conclusion:

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 >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *