I think Aditi's solution is correct. I was doing the same thing using XOR function... So basically I was saying to use XOR and interviewer was asking for something better... I could not find this solution...
Thanks Aditi. Thanks & Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved is bigger. P *We have a responsibility to the environment.* *Before printing this e-mail or any other document, let's ask ourselves whether we need a hard copy.* On Fri, Jul 22, 2011 at 10:19 PM, aditi garg <[email protected]>wrote: > I think this can be answered like dis... > let us say that the persons have decided amongst themselves that if the the > number of people wearing white in front of dem is even he wud say white and > if odd he wud say black.... > Now suppose the 100th person counts the number of hats and finds it to be > even... he wud say white... > now the 99th person will do the same...if he still finds the number to be > even and since the 100th person sed white(i.e even) he would say black...now > if the 100th person had sed black (ie odd white) and the count comes out to > be even thus 99 wud be wearing a white hat... > Now that 98th person knows dat 99 had sed the correct hat and using the > same method can say the correct hat color...thus all can be saved except the > 100th prisoner... > Also note dat the 100th prisoner also has a 50% chance to survive... > > Hope dis helps :) > > > On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari < > [email protected]> wrote: > >> could some1 plz post the xplainations ... >> >> >> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj <[email protected]>wrote: >> >>> Chetan, >>> >>> No. How could you relate this problem with that? Do you find something >>> similar? >>> >>> ~ >>> Pankaj >>> >>> >>> On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor < >>> [email protected]> wrote: >>> >>>> josehus problem??? >>>> >>>> >>>> On Fri, Jul 22, 2011 at 7:57 PM, Pankaj <[email protected]>wrote: >>>> >>>>> Skipp Riddle, >>>>> Yes. >>>>> 100th prisoner will risk his life. Similar puzzle was discuss recently. >>>>> Does anyone remember the name or thread? >>>>> >>>>> >>>>> ~ >>>>> Pankaj >>>>> >>>>> >>>>> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe <[email protected] >>>>> > wrote: >>>>> >>>>>> Worst case 99 get released. >>>>>> Is that correct..? >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Aditi Garg > Undergraduate Student > Electronics & Communication Divison > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY > Sector 3, Dwarka > New Delhi > > 9718388816 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
