Please answer its important to me

Pages: 12
You are an expert on paranormal activity and have been hired to locate a spirit haunting an old resort hotel. Strong signs indicate that the spirit lies behind one of four doors. The inscriptions on each door read as follows:

Door A: It’s behind B or C
Door B: It’s behind A or D
Door C: It’s in here
Door D: It’s not in here

Your psychic powers have told you three of the inscriptions are false, and one is true. Behind which door will you find the spirit?
Does it relate to C++?
ROFL a riddle, i take door D (only B is true). ^^
If your psychic powers are good enough to tell you that three are false and only one is true, then
why couldn't your psychic powers just give you the right answer?
Maybe because most people with psychic powers have a mental retardation?
This doesn't really have much to do with programming, more game design.... Maybe this riddle is more suited for Q&A sites like Y!A?
I don't see any reason we can't just open all the doors... >_>
I think the point was to use logic and find the contradictions
Why didn't he ask at the reception of the hotel?
This is easy.

A can't be true because if A is true then D is false but D being false contradicts A being true.
B must be true because if B is true then D is false, and if D is false then it must be behind D.
C is false because C being true would conflict with D being false
D is false because D being true conflicts with B being false.

It's B.
It's D.

C/D can't be true because then either A or B would also be true.
A can't be true because then either C or D would be true.
B is true. It can't be behind A because D would be true, so it is D, for which there are no contradictions.
Last edited on
I agree with Athar, but I prefer this reasoning:

A=b || c
B=a || d
C=c
D=!d

If D, then !A && !B && !C.
!A && !B == !(b || c) && !(a || d) == !b && !c && !a && !d.
If D isn't the correct answer, then no door is the correct answer.
@Athar,
Yeah, B is true like I said:
I wrote:
B must be true because if B is true then D is false, and if D is false then it must be behind D.

Why didn't he ask at the reception of the hotel?

The best reply I've seen so far :)) thx Bazzy^^
I prefer the reasoning that says that the spirit is behind the door which has only one reference.
Both B and D refer to A; A and D refer to B; A, C and D refer to C; only B refers to D. Therefore
the spirit is behind D.
I prefer the reasoning that says that it's not a question to be posted in general C++ forum
I prefer the reasoning that says that Bazzy is probably right and this thread ought to be deleted.
Let's make it relate to C++ ^_^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
using namespace std;

//the spirit is in...
bool A, B, C, D;

//inscriptions
bool IA() {return B||C;}
bool IB() {return A||D;}
bool IC() {return C;}
bool ID() {return !D;}

bool check()
{
    return IA()+IB()+IC()+ID()==1;
}

int main()
{
    char door;

    for (;;)
    {
        A=1;
        if (check()) {door='A'; break;}

        A=0;B=1;
        if (check()) {door='B'; break;}

        B=0;C=1;
        if (check()) {door='C'; break;}

        C=0;D=1;
        if (check()) {door='D'; break;}
    }

    cout << "The spirit is behind door ";
    cout << door << endl;

    cin.get();
    return 0;
}
Last edited on
I don't like it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

//inscriptions
inline int IA(int a){ return a==1 || a==2; }
inline int IB(int a){ return a==0 || a==3; }
inline int IC(int a){ return a==2; }
inline int ID(int a){ return a!=3; }

bool check(int a){
    return IA(a)+IB(a)+IC(a)+ID(a)==1;
}

int main(){
    int door=-1;
    char doors[]="ABCD";
    for (int a=0;a<4 && door<0;a++)
        if (check(a))
            door=a;
    if (door<0)
        std::cerr <<"Not found.\n";
    else
        std::cout <<"The spirit is behind door "<<doors[door]<<std::endl;
    return door>=0;
}
Last edited on
helios wrote:
I don't like it.

I don't care.
Pages: 12