Public Zone 公開區 > General Topics 綜合題目
Felix's puzzle
chin:
I am trying to work out the relationships...
轉貼
【1樓】某兩會委員發言:“上海是全世界的上海,上海的房價應該和國際接軌。我覺得80後男孩子如果買不起房子,80後女孩子可以嫁給40歲的男人。 80後的男人如果有條件了,到40歲再娶20歲的女孩子也是不錯的選擇。”
【2樓】回复: 我終於到40歲了,找到一個年輕貌美的20歲女友去她家見家長。開門的是當年讀大學時相處了幾年的初戀女友新女友喊了一聲:媽~
【3樓】補充:她媽看到我,驚得倒吸一口冷氣。沒等我反應過來,然後把女兒拉進房間裡,對女兒說“你不能和他在一起,他是你親生父親啊!”
【4樓】繼續補充: 女兒:我已經有了他的骨肉……
【5樓】 這時女孩的60多歲的父親走出來看見了女孩的男友,小聲的對他說:“你怎麼來了,給你媽和你的生活費不是每月都按時打去的?
【6樓】這時"叮咚",女孩男友的媽來見親家,見到女孩的父親:"怎麼是你"
【7樓】女孩男友的父親停完車也上樓了,一見女孩的父親馬上淚流滿面:"你不就是我失散多年的弟弟?"
【8樓】女孩母親見到男友母親:"媽"
【9樓】女孩母親見到男友他爸,叫了一聲“爹!”,立刻暈厥過去
請問—— 1、你能理解到幾樓? 2、男友他媽的媽見到女友他媽的爸叫什麼?
chin:
Let's have standard notations first...
B = the guy in question
G = the girl in question, and the current girlfriend of B
P(x) is bio paternal relationship, M(x) is bio maternal relationship, P+M(x) means the confirmed bio parents of x.
P'(x) & M'(x) denotes paternal or maternal relationship by marriage, although may nmot biologically
So here is my try
2. M(G) = early girlfriend of B
3. B = P(G)
4. B + G = P+M(?)
5. P'(G) = P(B)
6. just confirms 5
7. P'(B) = brother of P'(G)
8. M(B) = M(M(G))
9. P(B) = P(M(G))
Conclusion
- M(G) is sister of B, G is the offspring of brother & sister B + M(G) (G)!
女友他媽的爸 is the son in law of 男友他媽的媽
kido:
他媽的男友真是他媽的… ??? ???
kido:
--- Quote from: chin on 14 April 2011, 23:37:14 ---Let's have standard notations first...
B = the guy in question
G = the girl in question, and the current girlfriend of B
P(x) is bio paternal relationship, M(x) is bio maternal relationship, P+M(x) means the confirmed bio
...
--- End quote ---
Chin, your method reminded me my long forgotten computer language called 'Prolog', which is very suitable for this kind of problem.....and I'm going to illustrate my trial here ;D These are predicate logic which is mentioned in this thread.
First, I needed to tell the system some basic rules:
--- Quote ---parent_child(X,Y) :- father_child(X,Y).
parent_child(X,Y) :- mother_child(X,Y).
sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y), X\=Y.
--- End quote ---
(1) and (2) rules tell a parent_child relation is either it's a father_child relation or mother_child relation.
(3) rule tells a sibling relation between 2 is they share a common parent and they're not the same!!! Simple...
Now I'm going to tell the system the relation of these guys....
--- Quote ---mother_child(girlmom,girl).
gf_of(girlmom,boy).
father_child(boy,girl).
father_child(girldad,boy).
sibling(boydad,girldad).
mother_child(girlmom,boymom).
father_child(boydad,girlmom).
--- End quote ---
I hope I'm getting the above correct... To explain:
Rule (1) tells girlmom is mother of girl.
Rule (2) tells girlmom is girlfriend of boy.
etc.
Now I added in Prolog environment to see whether they're related, if you're familiar with recursion, it should be easy to understand below Rule (1), which says anything should related to himself. Others should be similar.
--- Quote ---related(X,X).
related(X,Y) :- father_child(X,Z), related(Z,Y).
related(X,Y) :- mother_child(X,Z), related(Z,Y).
related(X,Y) :- sibling(X,Z), related(Z,Y).
--- End quote ---
and I typed
--- Quote ---? - related(girldad,boymom).
Yes
--- End quote ---
Yes, they're related somehow....but how do I get their real relationship???
I further modified the related to
--- Quote ---related(X,X).
related(X,Y) :- father_child(X,Z), related(Z,Y), write(X), write(' is father of '), write(Z), nl.
related(X,Y) :- mother_child(X,Z), related(Z,Y), write(X), write(' is mother of '), write(Z), nl.
related(X,Y) :- sibling(X,Z), related(Z,Y), write(X), write(' is sibling of '), write(Z), nl.
--- End quote ---
Now I really tried it again:
--- Quote --- ?- related(girldad,boymom).
girl is sibling of boymom
boy is father of girl
girldad is father of boy
--- End quote ---
If you read the above reversely, you read their relation, which implies 'girldad' is grand-dad of boymom ???? I really don't know.
But I got the fun already!!!! :D :D :D :D
chin:
I am pretty drunk now after the dinner at the private kitchen....
I will try to understand the program flow when I am more "normal".
Navigation
[0] Message Index
[#] Next page
Go to full version