My issue
My code
import java.util.Scanner;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++)
{
int a = read.nextInt();
int b = read.nextInt();
int A=7-a;
int B=7-b;
// Update your code below this line to solve the problem
System.out.println(A);
}
}
}
Learning course: Solve Programming problems using Java
Problem Link: CodeChef: Practical coding for everyone
import java.util.Scanner;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++)
{
int a = read.nextInt();
int b = read.nextInt();
// Update your code below this line to solve the problem
if(7-a >= 7-b)
{
System.out.println(7-b);
}
else
{
System.out.println(7-a);
}
}
}
}
The problem here is that you are solving the question only for a particular person , you are not doing any comparison of the situaution , thus the logic will be to find the difference between the the total score and the actual score and then find the ssmalst one to reach the score of seven and here is the output you need for the question.
use this logic
// Update your code below this line to solve the problem
System.out.println(7-Math.max(a,b));