All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
The murderer in the Hotel (Posted on 2005-08-11) Difficulty: 2 of 5
Arlene(A), Brenda(B), Cheryl(C), Daniel(D), Emmett(E) and Farley(F) stayed in a hotel.

1) Each stayed in a different one of six rooms as shown here, identified by his initials :
         +----+----+----+----+
         |    | C  |    | E  |
         | B  +----+ D  +----+
         |    |    |    |    |
         +----+    +----+    +
         |      A  |      F  |
         +---------+---------+
2) One of the six murdered one of the other five.

3) If the murderer and the victim stayed in rooms that did not border on each other, then Arlene or Farley was the victim.

4) If the murderer and the victim stayed in rooms that bordered on different numbers of rooms, then Brenda or Cheryl was the murderer.

5) If the murderer and the victim stayed in rooms that were different in size, then Daniel or Emmett was the murderer.

Who was the murderer? Who was the victim?

See The Solution Submitted by pcbouhid    
Rating: 3.4444 (18 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution "Murder in the Hotel" revisited (program solution) Comment 59 of 59 |
  
  
  
Program solution in the Prolog language

Preparation
Transposition of the information given by the drawing
into an adjacency matrix:

      A    B    C    D    E    F    Number        Size
                                          of Bord.
--------------------------------------------------------
A    0    1    1    1    0    1       4                 big
B    1    0    1    0    0    0       2                 med
C    1    1    0    1    0    0       3                 sma
D    1    0    1    0    1    1       4                 med
E    0    0    0    1    0    1       2                 sma
F    1    0    0    1    1    0       3                  big

------------------------------------------------------
P r o g r a m
------------------------------------------------------

:- op(1050, xfy, =>).        %  Def.log.Operator '=>' for Conditional

P => Q :- + P, !.             %  (P -> Q) <=> (~P v Q)
P => Q :- Q.


b(a,4,3).                      %  1st Arg  = Person/Room
b(b,2,2).                      %  2nd Arg = Number of Bordering Rooms
b(c,3,1).                      %  3rd Arg  = Size: big=3, med=2, sma=1
b(d,4,2).
b(e,2,1).
b(f,3,3).

e(a,b).                         %  e(X,Y)  = Edge between X and Y,
e(a,c).                         %                 if '1' in matrix
e(a,d).
e(a,f).
e(b,a).
e(b,c).
e(c,a).
e(c,b).
e(c,d).
e(d,a).
e(d,c).
e(d,e).
e(d,f).
e(e,d).
e(e,f).
e(f,a).
e(f,d).
e(f,e).

solution(murd(M1),vict(V1)) :-

    b(M1,Bm,Sm),b(V1,Bv,Sv),

    dif(M1,V1),


    (+ (M1=b ; M1=c) => (Bm=:=Bv) ),        % Contrapos. of 4)

    (+ (M1=d ; M1=e) => (Sm=:=Sv) ),        % Contrapos. of 5)

    (+ (V1=a ; V1=f) => ( e(M1,V1) ).           % Contrapos. of 3)

-----------------------------------------          
Q u e r y
-----------------------------------------

?- solution(M,V).
   
M = murd(d),

V = vict(a).



Edited on June 29, 2017, 3:40 pm
  Posted by ollie on 2017-04-11 15:16:33

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information