Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

The Old Saint And Three Questions CodeChef Solution

Problem – The Old Saint And Three Questions CodeChef Solution

Once upon a time, there was a hero and an old saint. And like in any story with a hero and an old saint, the old saint asked the hero — three questions!

But here’s the twist: each question was a binary question, which means that the answer to each must be either a ‘Yes’ or a ‘No’, not none, not both. Our hero, who was not so wise in the ways of science, answered them arbitrarily and just hoped he is correct. The old saint, being so old, does not remember which answers were correct. The only thing that he remembers is – how many of them were ‘Yes’, and how many of them were ‘No’. Our hero will pass the test if the old saint cannot distinguish his responses from the set of correct answers i.e. if the number of ‘Yes’ and ‘No’ in the responses matches that in the correct answers, regardless of their order.

You are given the answers to each of the three questions, and the responses of the hero to the same. Find whether the hero will be able to pass the old saint’s test.

Input Format

  • First line will contain T, the number of test cases. The description of the test cases follow.
  • The first line of each test case consists of three space-separated integers A1​ A2​ A3​, representing the correct answers to the first, second, and third question respectively (0 for ‘No’, 1 for ‘Yes’).
  • The second line of each test case consists of three space-separated integers B1​ B2​ B3​, representing the response of the hero to the first, second, and third question respectively (0 for ‘No’, 1 for ‘Yes’).

Output Format

For each test case, print “Pass” (without quotes) if the hero passes the old saint’s test, “Fail” (without quotes) otherwise.

Constraints

  • 1≤T≤64
  • 0≤Ai​,Bi​≤1

Sample 1:

Input:
2
1 0 1
1 1 0
0 0 0
1 1 1
Output:
Pass
Fail

Explanation:

  • In the first test case, since the number of 1s (Yes) is 2, and the number of 0s (No) is 1 among both the correct answers and the hero’s answers, the old saint will fail to distinguish. Hence, the hero passes the test.
  • In the second test case, the number of 1s (Yes) is 0 among the correct answers but 3 among the hero’s responses. Similarly, the number of 0s don’t match. Therefore, the old saint will be able to call the differences between the correct answer and the hero’s response. Hence, the hero fails the test.

The Old Saint And Three Questions CodeChef Solution in Pyth 3

# cook your dish here
t = int(input())
for i in range(0,t):
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    if sum(a)==sum(b): print("Pass")
    else: print("Fail")

The Old Saint And Three Questions CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
    int T,A[3],B[3];
    cin>>T;
    for(int i=0;i<T;i++){
        int p=0,P=0,n=0,N=0;
        for(int j=0;j<3;j++){
            cin>>A[j];
            if(A[j]==0) n++;
            if(A[j]==1) p++;
        }
        for(int j=0;j<3;j++){
            cin>>B[j];
            if(B[j]==0) N++;
            if(B[j]==1) P++;
        }
        if(p==P && n==N) cout<<"Pass"<<endl;
        else cout<<"Fail"<<endl;
    }
	return 0;
}

The Old Saint And Three Questions CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for(int i=0;i<t;i++){
		    int a=sc.nextInt();
		    int b=sc.nextInt();
		    int c=sc.nextInt();
		    int d=a+b+c;
		    int p=sc.nextInt();
		    int q=sc.nextInt();
		    int r=sc.nextInt();
		    int s=p+q+r;
		    if(d==s){
		        System.out.println("Pass");
		    }
		    else{
		        System.out.println("Fail");
		    }
	}}
}
The Old Saint And Three Questions CodeChef Solution Review:

In our experience, we suggest you solve this The Old Saint And Three Questions 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 The Old Saint And Three Questions CodeChef Solution

Find on CodeChef

Conclusion:

I hope this The Old Saint And Three Questions 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 *