The Old Saint And Three Questions Problem Code: THREEQ


 


The Old Saint And Three Questions Problem Code: THREEQ


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

2

1 0 1

1 1 0

0 0 0

1 1 1

Sample Output 1 

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.

Author: 6★hitch_hiker42

Date Added: 30-08-2021

Time Limit: 0.5 secs

Source Limit: 50000 Bytes

Languages: CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM




Solution In C


#include <stdio.h>


int main(void) {

    int t;

    scanf("%d",&t);

    while(t--){

        int a[2],b[2],c1=0,c2=0;

        for(int i=0;i<=2;i++){

            scanf("%d",&a[i]);

            if(a[i]==1)

            c1++;

        }

        for(int i=0;i<=2;i++){

            scanf("%d",&b[i]);

            if(b[i]==1)

            c2++;

        }

        if(c1==c2)

        printf("Pass\n");

        else

        printf("Fail\n");

    }

    


}

Comments

Popular posts from this blog

Airline Restrictions Solution September Challenge 2021 (Rated for Div 3)

Minimize Digit Sum Solution | Codechef September long challenge 2021

Maximise the Subsequence Sum Problem Code: SIGNFLIP Codechef Solution

10 things you need to know about SpaceX

THE TOP 10 PAID BLOGGERS IN 2020

THE TOP 10 YOUTUBERS IN 2020

Travel Pass | Codechef September long challenge 2021 | Travel Pass Solution

2-D Point Meeting Solution | Codechef September long challenge 2021

Say No To Drugs Problem Code: NODRUGS