Solving the puzzle using sets. Building a microworld for the set theory. Then the puzzle is just a math problem. I don't know the exact english names so corrct the names if necessary. Union : the set of elements member of :a or member of :b Each element only once. to union :A :B op remdup se :A :B end Intersection: The set of elements member of :A and member of :B to inter :A :B op filter [memberp ? :A] :B end Complement: set of elements of :R not in :A to compl :A :R op filter [not memberp ? :A] :R end Product: All couples made of an element of :a and an element: of :B to setproduct :A :B op (crossmap [list ?1 ?2] :A :B) end And now let play. You can try writing commands in the commander. The world of the puzzle. make "cup [China Japan] make "century [3 4 5] What the experts are saying. make "cupa [China] make "cupb [Japan] make "cupc compl [China] :cup show :cupc [Japan] make "centurya[5] make "centuryb[3] make "centuryc[4] If The cup is true The Century is false . make "expa1 setproduct :cupa compl :centurya :century show :expa1 [[China 3] [China 4]] make "expb1 setproduct :cupb compl :centuryb :century show :expb1 [[Japan 4] [Japan 5]] make "expc1 setproduct :cupc compl :centuryc :century show :expc1 [[Japan 3] [Japan 5]] If the cup is false the century is true. make "expa2 setproduct compl :cupa :cup :centurya show :expa2 [[Japan 5]] make "expb2 setproduct compl :cupb :cup :centuryb show :expb2 [[China 3]] make "expc2 setproduct compl :cupc :cup :centuryc show :expc2 [[China 4]] All each expert can say. make "expa union :expa1 :expa2 show :expa [[China 3] [China 4] [Japan 5]] make "expb union :expb1 :expb2 show :expb [[Japan 4] [Japan 5] [China 3]] make "expc union :expc1 :expc2 show :expc [[Japan 3] [Japan 5] [China 4]] The truth should be sayed by all experts. show inter :expa inter :expb :expc [[Japan 5]] Copy all that in the editor , keep what is necessary to build the program. Sorry that set theory is no more a part of the curriculum of our pupils (12 - 15) in Geneva ... I don't know about yours. Original : >> To: logo-l@gsn.org >> Date: Sun, 18 Jan 1998 23:38:34 -0700 >> From: "Dreyfuss Pierre-Andre" <p.a.dreyfuss@mailexcite.com> >> Cc: olgatu@hotmail.com >> Subject: : Re: LOGO-L> Logical Puzzle >> Organization: MailExcite (http://www.mailexcite.com) >> Reply-to: "Dreyfuss Pierre-Andre" <p.a.dreyfuss@mailexcite.com> > >Thank Erich Neuwirth and Pierre-Andre for introducing me to such an >interesting approach to logic puzzle solving. Especially I like the >one-line solution: > print filter[memberp ? :experta]filter[memberp ? :expertb] :expertc > >(BTW, Pierre-Andre, there was a minor typo in this line. It was >obvious, I just want to show, I investigated the message carefully. >:-)) > >And, I find it suitable for educational aims, that for this solution >half of the work should be done in the student's head. But, for this >approach I should introduce students to maps and filters. I'm not >sure, it's trivial. At least, I have had no experience of that kind >by far. I think, the most difficult part of it might be templates. By >now I have no ideas how it could be done on the "school level". Any >suggestions? > >Regards, >Olga. > >> Hello Olga, >> >> Here is a solution that is not too difficult for your pupils. >> >> The basic I Idea is that we can build a set of affirmations that could be true for >> each expert. >> >> Each affirmation is a list of country century >> Expert A :[ China 4] [China 3] [Japan 5] >> >> Expert B : [ Japan 4] [Japan 5] [China 3] >> >> Expert C :(changing not China into Japan) >> >> [Japan 3] [Japan 5] [China 4] >> >> make "experta [[China 4] [China 3] [Japan 5]] >> make "expertb [[Japan 4] [Japan 5] [China 3]] >> make "expertc [[Japan 3] [Japan 5] [China 4]] >> >> Now the problem is to find which affirmation is the same for all experts. >> >> It is the intersection of the three lists. >> >> The library primitive FILTER does the job. >> >> print filter[memberp ? :experta]filter[memberp ? :expertb] :experta Will give the >> solution. [Japan 5] >> >> If you want the computer to build the affirmations then use the procedure assert >> below. >> >> to assert :name :cupexp :centuryexp >> make :name ~ >> se map [list :cupexp ? ] ~ >> filter [not ? = :centuryexp] :century ~ >> map [list ? :centuryexp] ~ >> filter [not ? = :cupexp] :cup >> end >> >> to solution >> local "expa >> local "expb >> local "expc >> >> assert "expa "china 5 >> assert "expb "japan 3 >> assert "expc "japan 4 >> print filter [memberp ? :expa] ~ >> filter [memberp ? :expb] :expc >> end >> >> You can disgard the local declarations. >> >> Sincerly, >> Pierre-AndrE Dreyfuss >> Olga wrote . >> >Hello everybody, >> > >> >I'm intruding on your recursion discussion with very different problem. >> >I haven't seen this kind of problems there, but may be somebody is >> >interested, or has had an experience in solving them. >> >The problem is from a "logical field". >> > >> >For example let's formulate it as follows. >> > >> >Three experts are having discussion about an ancient cup. >> > >> >Expert A: This is a China cup from the 5th century, >> >Expert B: This is a Japan cup from the third century, >> >Expert C: This is not a China cup, it was made in the 4th century. >> > >> >It turned out, only one of two statements of each expert was right, the >> >> >other was wrong. >> > >> >What country and what century does the cup belong? >> >---------------- >> > >> >I think, the main idea of the solution is standart. >> > >> >Le's denote with C the statement "the cup is from China", >> > J - "from Japan", >> > T - "it was made in the third century", >> > F - " in the 4th century", >> > V - " in the 5th century". >> > >> >We should find such boolean values of C J T F V, which make the >> >following statements "true": >> > or (and C not V)(and not C V) >> > or (and J not T)(and not J T) >> > or (and not not C F)(and not C not F) >> >Also: >> > not and T F >> > not and T V >> > not and F V >> > not and C J. >> > >> >The solutions that I've seen, all use looking over(?) all the possible >> >> >combinations of values of C, J, T, F, V. It doesn't look great. I tried >> >> >to present these combination as a binary code (binary representation of >> >> >the number from 0 through 31), but not sure it improves the solution >> >much. >> >Would be greatful for any ideas and suggestions. Also, does anybody work >> >> >on such problems this way or other with the school children? >> > >> >The solution presented below, says, that the cup was from Japan and was >> >> >made in the 5th century. >> > >> >Thanks, >> >Olga. >> >--------------------------------- >> >to logic.main >> >for [i 0 31][if (and bool1 c :i v :i ~ >> > bool1 j :i t :i ~ >> > bool2 c :i f :i ~ >> > bool3 c :i j :i ~ >> > bool3 t :i f :i ~ >> > bool3 t :i v :i ~ >> > bool3 f :i v :i)~ >> > [(pr c :i j :i t :i f :i v :i)]] >> >end > > >> >to c :i >> >op int :i/16 >> >end >> > >> >to j :i >> >op remainder int :i/8 2 >> >end >> > >> >to t :i >> >op remainder int :i/4 2 >> >end >> > >> >to f :i >> >op remainder int :i/2 2 >> >end >> > >> >to v :i >> >op remainder :i 2 >> >end >> > >> >to bool1 :c :v >> >output or (and l :c not l :v) (and l :v not l :c) >> >end >> > >> >to bool2 :c :f >> >output or (and not not l :c l :f)(and not l :c not l :f) >> >end >> > >> >to bool3 :c :j >> >output not and l :c l :j >> >end >> > >> >to l :a >> >ifelse :a=1 [op "true][op "false] >> >end >> >------------------------------- > Free web-based email, Forever, From anywhere! http://www.mailexcite.com --------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home