File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programming Diversions and the fly likes [Easy]Road to capital Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "[Easy]Road to capital" Watch "[Easy]Road to capital" New topic
Author

[Easy]Road to capital

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1871
I have taken this problem from 'Discrete Mathematics' by C N Liu.
In one country ,all people always lie or always talk truth.These people always answer in the form of 'Yes/No' ONLY.One tourist is visiting this country and saw the inhibitant sitting near a junction.One road goes to capital of the country and another goes to desert.Tourist wants to go to capital.By asking ONLY ONE question,tourist should find the road which goes to capital.
What question should tourist ask to inhibitant?
[ August 11, 2003: Message edited by: Capablanca Kepler ]
[ August 11, 2003: Message edited by: Capablanca Kepler ]

MH
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
the question will be like
"if i ask your friend, "which road leads to the desert ? what will be his answer? "
the traveller should take the other road to go to the capital.
Let us take all are telling the truth if we ask the question, his friend should say the correct road to the desert and he also will say the same road to desert. so now we can take the other road to go to the capital.
if all are telling lies and if we ask the question his friend should say the wrong road(road to the capital) and as he is a liar he wont say the same road and say the road to the desert. so now we can take the other road to go to the capital.


Karthikeyan<br />SCJP 1.4, SCWCD.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
"if i ask your friend, "which road leads to the desert ? what will be his answer? "
First, what friend? The question only mentioned one person by the road.
Second, even if there are two people present (or maybe you can talk about some other friend even though he's not physically there), why assume that either they're both liars, or both truthful? Maybe one's a liar and the other's truthful. Then your answer won't work.


"I'm not back." - Bill Harding, Twister
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1871
Originally posted by Jim Yingst:
"if i ask your friend, "which road leads to the desert ? what will be his answer? "
First, what friend? The question only mentioned one person by the road.
Second, even if there are two people present (or maybe you can talk about some other friend even though he's not physically there), why assume that either they're both liars, or both truthful? Maybe one's a liar and the other's truthful. Then your answer won't work.

Jim,the ALL people are either speak truth or ALL people speak false.People are not divided there.
Karthink was almost right.
Tourist should ask "If I ask any person from your country that does the road to the left goes to capital,Will he answer Yes?"
[ August 12, 2003: Message edited by: Capablanca Kepler ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Not sure about this...
"Would your answer be 'Yes' if I asked is this the way to the Capital"
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1871
If all people(i.e. me too)truth speaking and if the road to the left goes to capital,my answer will be Yes.If all people(i.e. me too) are liars (and road to left goes to capital)then also my answer will be Yes.So if answer is Yes then tourist can conclude that road to left goes to capital.
On the other hand if all people are truth speaking and road to capital goes to right,then my answer will be No.Whereas if all the people are liars and road to right goes to capital,still my answer be No.So tourist can conlude if answer is No,road to right must be going to capital.
[ August 12, 2003: Message edited by: Capablanca Kepler ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Jim,the ALL people are either speak truth or ALL people speak false.People are not divided there.
Really? Well, that's a new version. I couldn't tell that from your initial problem statement. Anyway, I like Michael Dunn's answer, as it works regardless of how other people on the island behave. (Or even if there's no one else on the island.) See also this post, including Joel McNary's version.
[ August 12, 2003: Message edited by: Jim Yingst ]
Vivek Kumar
Greenhorn

Joined: Sep 23, 2003
Posts: 9
I agree with Jim. The original version suggests that 'any' person on island either always seaks truth or always speak lie. Still, the answer given by karthikeyan is correct.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Easy]Road to capital
 
Similar Threads
India to prepay $3 billion on debts
[easy]Find the number
Huge database access
Is the staying in the US so compelling?
Clock problem