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-André 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
>-------------------------------
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.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.
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