Logic Quiz

Re: Logic Quiz

Okay to me, the question is a pure brute force i.e., you pick a prime number and figure your way up ... I could have done it on papers but i didn't have anything available so i wrote a Java program



public class PsyahQuestion {
    static int *a*;
    static int *b*;
    static int *c*;


    public static void main (String] args){
        int] primeNumbers = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

        for (int pk : primeNumbers) {
            *calculate*(pk);
System.*out*.printf("a = %d, b = %d, c = %d, pk = %d
", *a*, *b*, *c*, pk);
}
    }

    private static void calculate(int pk) {
        for (int i = 1; i <= 100; i++){
            for (int j = 1; j <= 100; j++){
                *a *= i;
*b *= j;

                if ((i != j) && (i/j == pk)){
                    if (i * j < 100) {
                        *c *= i * j;

                        if (*c ** pk > 100){
                            return;
}
                    }
                }
            }
        }
    }
}


and the output is



a = 11, b = 5, c = 55, pk = 2
a = 12, b = 4, c = 48, pk = 3
a = 11, b = 2, c = 22, pk = 5
a = 14, b = 2, c = 28, pk = 7
a = 11, b = 1, c = 11, pk = 11
a = 13, b = 1, c = 13, pk = 13
a = 17, b = 1, c = 17, pk = 17
a = 19, b = 1, c = 19, pk = 19
a = 23, b = 1, c = 23, pk = 23
a = 29, b = 1, c = 29, pk = 29
a = 31, b = 1, c = 31, pk = 31
a = 37, b = 1, c = 37, pk = 37
a = 41, b = 1, c = 41, pk = 41
a = 43, b = 1, c = 43, pk = 43
a = 47, b = 1, c = 47, pk = 47
a = 53, b = 1, c = 53, pk = 53
a = 59, b = 1, c = 59, pk = 59
a = 61, b = 1, c = 61, pk = 61
a = 67, b = 1, c = 67, pk = 67
a = 71, b = 1, c = 71, pk = 71
a = 73, b = 1, c = 73, pk = 73
a = 79, b = 1, c = 79, pk = 79
a = 83, b = 1, c = 83, pk = 83
a = 89, b = 1, c = 89, pk = 89
a = 97, b = 1, c = 97, pk = 97


Re: Logic Quiz

:smack: Bhaijan thats supposed to be a “logic quiz” not a programming contest :halo:

Re: Logic Quiz

haha, i know … I cheated. but there is no logic in this quiz from my perspective. its all brute force. Start from the prime factor (X) and move your way up :frowning:

Re: Logic Quiz

^ :lajawab:

Re: Logic Quiz

Nevermind..see it now.

Re: Logic Quiz

Could it be A=14 and B=7?

Re: Logic Quiz

Brother MustafaQuraishi

I love your answer ... But it is a bit easier than that ... You are right there is some "brute force" needed.

The program is not giving the correct answer, but I like it ...

Re: Logic Quiz

“public class PsyahQuestion {”

:omg:

Re: Logic Quiz

From the question we know that AB < 100

If A is 1 then B must be 99 or less all the way to 2
If A is 2 then B must be 49 or less all the way to 2
in this way we find all the maximum B values for each A.

From A = 50 upwards all Bs are =1

since A/B must be prime therefore only those numbers from 50 to 99 are allowed that are themselves prime, be ause B = 1.

but for lower values of A than 50, B values increase

There are too many B = 1 so all of them are invalid as we are only looking for a combination where B = x twice only, whilst fitting the above criteria.

The shortlist of numbers should be:

A, B, A/B, AB

4, 2, 2, 8
6, 2, 3, 12
10, 2, 5, 20
14, 2, 7, 28
22, 2, 11, 44
34, 2, 17, 68
38, 2, 19, 76
46, 2, 23, 92

6, 3, 2, 18
9, 3, 3, 27
15, 3, 5, 45
21, 3, 7, 63
33, 3, 11, 99

8, 4, 2, 32
20, 4, 5, 80

10, 5, 2, 50
15, 5, 3, 75

12, 6, 2, 72

As can be seen from this shortlist only B= 4 and B=5 are possible solutions since they are the only b values that give exactly 2 possible combinations.

Now we apply CX > 100 to these four ...

so for (A=8, B=4) CX = 64
.....for (A=20, B=4), CX =400
.....for (A=10, B=5), CX =100
.....for (A=15, B=5), CX = 225

hence solution is A = 20 when B = 4 or A=15 when B = 5

Re: Logic Quiz

I personally think MustafaQuraishi you have put too many nested functions together and it seems to have skipped out steps.

Try rewriting the Java program first by dumping the values of AB < 100 when A/B is Prime into an array. Your prime number object need not be so long because for prime numbers higher than 50 B values will always be 1 ... And there are too many of them to qualify as possible answers.

I notice your first result a = 11, b=5 is giving a pk of 2 ... This is probably because when you divide two int values it will give the answer as an int. So it truncated .5 from the 2.5 to give 2. Of course that is not right and you might need to use a double.

Re: Logic Quiz

AB here will be greater than 100

Answer is on #149](http://www.paklinks.com/gs/usertag.php?do=list&action=hash&hash=149)

Re: Logic Quiz

hmm… maybe i’ve been using the calculator a lot, but isnt 14*7=98?

Re: Logic Quiz

I didn't give much thought to this code. I wrote it in literally 10 minutes. There are more bugs than the int thing :)

I will update the code tomorrow morning. really really sleepy right now.

Re: Logic Quiz

Nawa Aya hai soniya ​:what:

Re: Logic Quiz

i was lost in A & B having two combinations that couldnt progress any further :bummer:

Bhayyon kuch “logical” poocho..

Re: Logic Quiz

B =4
A = 12, 20
AB = 48, 80 < 100
A/B = 3, 5 Prime
CX = CA/B= ABA/B= A^2
CX = 144, 400 > 100

Next number 28 does not satisfy ab < 100 condition

So b =4
A = 12, 20

Re: Logic Quiz

The quiz asked what is one value of B which gives exactly two solutions for A

B is equal to 4. A is 12 and 20.

Re: Logic Quiz

B is such that there are exactly two possible solutions for A.

Means b is 4. A is 12 and 20. Two solutions.for a per problem statement

Re: Logic Quiz

Whoppsy … Yes you right my bad ! … 14 and 7 is also a combination that is possible so it should be in my list on post #139](http://www.paklinks.com/gs/usertag.php?do=list&action=hash&hash=139)

however, if there is not another combination where B = 7 then this combination must be eliminated anyway … Can you find another one where B =7 for different A value?

Re: Logic Quiz

Sort of ... If you see when B = 5 you also get exactly two solutions for A so there are actually four correct combinations until you workout CX > 100

in which case only one of the B=4 and only one of the B=5 combos qualify.