Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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.
For each test case, print “Pass” (without quotes) if the hero passes the old saint’s test, “Fail” (without quotes) otherwise.
Input:
2
1 0 1
1 1 0
0 0 0
1 1 1
Output:
Pass
Fail
# 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")
#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;
}
/* 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");
}
}}
}
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
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 >>