Go Back   Science Forums
View Single Post
Old 01-04-2009   #9 (permalink)
CraigD's Avatar
CraigD
Creating


Location:
Silver Spring, MD, USA
 
CraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond repute
 



Not Ranked  0 score     
Post Sherlock, the Zebra Puzzle, the Fish Puzzle - logic puzzles in general

Sorry to have ignored this thread for the past week

I get an “installer corrupt or incomplete” message when attempting to run the windows installer downloaded from Flowix Games, so haven’t tried the game yet. I found this copy of a game called “Sherlock”, which seems to be the same game, and finally gave it a try. I finished its first (and presumably easiest) game in an rather pathetic 13:58, though I’m sure I’d get quicker with repeated playing.

“Einstein’s puzzle” usually refers to a 5x5 (rather than Sherlock’s 6x6) logic puzzle called the “Zebra Puzzle”, which, legend has it, either Albert Einstein or Lewis Carol claimed only about 2% of people could solve. Usually speed isn’t considered much in solving logic puzzles – an experienced logic puzzle solver typically takes 10 to 30 minutes, using paper and pencil or equivalent, much of the time spent organizing the attributes and clues, which computerized version do for you.

Some logic puzzles termed “Einstein’s puzzle”, such as the “Fish” variation, can be solved with a “single pass”, while the usual Zebra variation needs 2 guesses, each with 2 possibilities, so may need 4 trys to solve the puzzle.

Here’s a small MUMPS program that can solve the Zebra Puzzle, but not the Fish Puzzle – that is, can’t try guesses:
Code:
x X(1),X(4) ;X: logic puzzle solver
k B,D,BD s N=5,I="" f  s I=$o(X(2,I)) q:I=""  f J=1:1:N f K=1:1:N s V=$p($p(X(2,I)," ;"),",",J),B(K,I,V)="",BD(I,V)="",D(V)=I ;X(1): init B()
n (X,B,D,BD,N,XWR,C) s (C0,S)="" f  s S=$o(X(3,S)) x X(5),XWR q:S=""&(C=C0)!'C  s:S="" C0=C i S]"" s VV=$p(X(3,S)," ;") x X(4,$p(VV,",")) ;X(4): solve
s V=$p(VV,",",2),I=D(V),K=$p(VV,",",3) zt:'$d(B(K,I,V))  k B(K,I) s B(K,I,V)="" ;X(4,1): is in #
s V1=$p(VV,",",2),I1=D(V1),V2=$p(VV,",",3),I2=D(V2),KI=$p(VV,",",4) f K=1:1:N k:'$d(B(K-KI,I1,V1)) B(K,I2,V2) k:'$d(B(K+KI,I2,V2)) B(K,I1,V1) ;X(4,"="): is/is to left or right of
s V1=$p(VV,",",2),I1=D(V1),V2=$p(VV,",",3),I2=D(V2),KI=$p(VV,",",4) f K=1:1:N k:'$d(B(K-KI,I1,V1))&'$d(B(K+KI,I1,V1)) B(K,I2,V2) k:'$d(B(K-KI,I2,V2))&'$d(B(K+KI,I2,V2)) B(K,I1,V1) ;X(4,"+-="): is next to
n (X,B,N,C) x X(5,1),X(5,2) s C=V]"" x X(5,3) i C s Q="B" f C=0:1 s Q=$q(@Q) q:Q="" ;X(5): check for uniques & clean
s (K,I,V)="" f  s K=$o(B(K)) q:'K  f  s I=$o(B(K,I)) q:I=""  f  s V=$o(B(K,I,V)) q:V=""  s (C1,B1(I,V))=$g(B1(I,V))+1,B1(I,V,K)="",B2(I,V)=K k:C1>1 B2(I,V) ;X(5,1)
s I="",V=1 f K=1:1:N q:V=""  f  s I=$o(X(2,I)) q:I=""  s V=$o(B(K,I,"")) q:V=""  i $o(B(K,I,V))="" k B2(I,V) f KK=1:1:N k:KK-K B(KK,I,V) ;X(5,2)
s (K,V)="" f  s I=$o(B2(I)) q:I=""  f  s V=$o(B2(I,V)) q:V=""  s K=B2(I,V) k B(K,I) s B(K,I,V)="" ;X(5,3)
Here’s the data that defines the Zebra Puzzle:
Code:
Blue,Green,Red,White,Yellow ;X(2,"Color")
Brit,Dane,German,Norwegian,Swede ;X(2,"Nationality")
Beer,Coffee,Milk,Tea,Water ;X(2,"Beverage")
Blue Master,Dunhill,Pall Mall,Prince,Blend ;X(2,"Cigar brand")
Cats,Birds,Dogs,Fish,Horses ;X(2,"Pet")

=,Brit,Red ;X(3,1): The Brit lives in a red house.
=,Swede,Dogs ;X(3,2)
=,Dane,Tea ;X(3,3)
=,Green,White,1 ;X(3,4): The green house is on the left of the white, next to it.
=,Green,Coffee ;X(3,5)
=,Pall Mall,Birds ;X(3,6)
=,Yellow,Dunhill ;X(3,7)
1,Milk,3 ;X(3,8)
1,Norwegian,1 ;X(3,9): The Norwegian lives in the first house
+-=,Blend,Cats,1 ;X(3,10): The man who smokes Blends lives next to the one who keeps cats
+-=,Horses,Dunhill,1 ;X(3,11)
=,Blue Master,Beer ;X(3,12)
=,German,Prince ;X(3,13)
+-=,Norwegian,Blue,1  ;X(3,14)
+-=,Blend,Water,1 ;X(3,15)
This program can only process 5 types of rules, using 3 subroutines, but it only need 4 of them for the Zebra Puzzle. Sherlock would need a few more kinds of rule processors. Many logic puzzles would need even more. I’m unaware of any comprehensive review and catalog of these rule types, or an estimate or precise proof of how many there are.


----------------
Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies
Reply With Quote
 
» Advertisement
» Current Poll
Who's the sexiest man alive? Johnny Depp or Robert Pattinson?
Johnny Depp - 27.27%
3 Votes
Robert Pattinson - 0%
0 Votes
Someone else (please specify) - 45.45%
5 Votes
I'm too macho to think a guy is sexy - 27.27%
3 Votes
Total Votes: 11
You may not vote on this poll.


All times are GMT -8. The time now is 04:53 PM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000-2009 Hypography
Part of the Hypography - Science for Everyone Network