Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Prisoners problem....

This is a discussion on Prisoners problem.... within the Challenging puzzles forums, part of the Brain Gym category; Here is one of the famous challenging puzzle... There are 100 prisoners assigned by numbers in 1 to 100 . Any number can be assigned to them . They need ...

Go Back   Geeks Talk > Brain Gym > Challenging puzzles
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 08-13-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
Prisoners problem....

Here is one of the famous challenging puzzle...

There are 100 prisoners assigned by numbers in 1 to 100 . Any number can be assigned to them . They need not be unique. They can talk one time before they assigned and then don't have any connection. Each one is requested to guess his number (they can use different strategies). He can see their numbers (but not their guess).
How can they do it so at least one of them guesses correctly his number?
__________________
Cheers,
:) James:)
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-17-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,016
Thanks: 0
Thanked 91 Times in 72 Posts
psuresh1982 will become famous soon enough
Re: Prisoners problem....

Hi James,

I think if you assigned the unique number for prisoner then only we have a solution. Otherwise according to my knowledge there is no general solution for this problem...

If you have a solution then post here...i will find the error.

-------------------
suresh
Reply With Quote
  #3 (permalink)  
Old 08-17-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
Re: Prisoners problem....

I have the solution for this problem. Let us wait for few more days so that others can give a try.

Definitely you will be having the solution in this thread by the next week end. It can be either from me or from some one else
__________________
Cheers,
:) James:)
Reply With Quote
  #4 (permalink)  
Old 08-27-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,016
Thanks: 0
Thanked 91 Times in 72 Posts
psuresh1982 will become famous soon enough
Re: Prisoners problem....

Hi James,

We are all waiting for the solution for this problem....Almost 10 days over...

--------------------
suresh
Reply With Quote
  #5 (permalink)  
Old 08-29-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
Re: Prisoners problem....

Sorry for the delay to post my solution.

Let us assume that the sum of all number assigned to 100 prisoners is S(P) and the number assigned to the first prisoner is n1, the number to the second prisoner is n2 and so on.

That is, S(P) = n1 +n2+n3 +...+n100.

And it is obvious that Mod(S(P),100) ranges between 0-99.

Here is my strategy that must work in all cases,

The first prisoner always assumes that "Mod(S(P),100)" is going to be 0
The second prisoner assumes that "Mod(S(P),100)" is going to be 1
so on...

It is certain that exactly one of the 100 prisoners is right with his guess.

Now, The first prisoner in his turn
1. Add all numbers assigned to rest of the people (n2+n3+...+n100). Let us say the value is S(p1).
2. Find "Mod(s(p1),100)". Let us say he has got the number np1.
3. Find 100 -np1, which is going to be his guess. Since he guess that "Mod(S(P),100)" is going to be 0

Let be brief this with an example.

Let use assume that he has got 5078 at the end of first step

Step2 mod(5078,100) = 78
Step3 100 -78 = 22
Hence the guess will be made by the first prisoner is 22.

Now, The second prisoner
1. Add all numbers assigned to rest of the people (n1+n3+...+n100). Let us say the value is S(p2).
2. Find "Mod(s(p2),100)". Let us say he has got the number np2.
3. Find 100+1 -np2, which is going to be his guess.

Example if the second person got 5078 at the end of first step then his guess would be 100 + 1 -78 = 23.


All other 99 prisoners also will make their guess as described above. It is obvious that one their guess on value of "Mod(S(P),100)" must be right. Hence that prisoner's guessing on the number assigned him will also be right.
__________________
Cheers,
:) James:)
Reply With Quote
  #6 (permalink)  
Old 08-29-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,016
Thanks: 0
Thanked 91 Times in 72 Posts
psuresh1982 will become famous soon enough
Re: Prisoners problem....

Hi James,

For example if i assigned the numbers for first prisoner is 90 and other prisoners for 2.

According to your solution First prisoner guess is (198 mod 100) = 98
Next 100-98 = 2 => wrong

Second prisoner guess is (286 mod 100) = 86
Next 100+1 - 86 = 15

Third prisoner guess is (286 mod 100) = 86
Next 100+2 - 86 = 16
.
.
.
so on...

Here which prisoner guess goes right? If i am wrong then correct me...

-----------------------
suresh
Reply With Quote
  #7 (permalink)  
Old 08-30-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
Re: Prisoners problem....

let us take 89th prisoner . He guesses that the reminder is going to be 88

Hence his guess would be 100+88 -86 =102 (mod 100) = 2

Hope this clears your doubt
__________________
Cheers,
:) James:)
Reply With Quote
  #8 (permalink)  
Old 10-03-2008
Junior Member
 
Join Date: Jul 2008
Location: Thane
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
vasudeo007 is on a distinguished road
Re: Prisoners problem....

James bhai, tera ye sawaal ekdam vague hai. I believe that the only person who can guess his number correctly is 100th.

You have tried to apply your maths well, but it does not seem to work. At least for me.
Reply With Quote
  #9 (permalink)  
Old 12-18-2008
Junior Member
 
Join Date: Oct 2008
Location: Hamden, CT USA
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
richardpaulhall is on a distinguished road
Re: Prisoners problem....

Much simpler answer;

Have every Prisoner guess the same number!
Reply With Quote
Reply

  Geeks Talk > Brain Gym > Challenging puzzles

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
IE 7.0 and QTP 9.1 problem abhychar07 QTP 0 06-08-2007 09:34 AM
escalator problem... psuresh1982 Brainteasers 15 03-21-2007 02:41 AM
div tag problem... psuresh1982 JavaScript 3 02-03-2007 09:05 AM
Problem with awk sharifhere Unix/Linux 12 01-17-2007 05:12 AM
Cellspacing problem..... psuresh1982 Web Design 1 01-14-2007 10:00 AM


All times are GMT -4. The time now is 06:10 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved