Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The question "what is the gender of one of your children" gives you some information about the gender of both of their children. It's enough information to eliminate the case where both children are the gender opposite the one they mentioned.

It can still be the case that the chances of there being a boy and a girl are 1/2, while the chances of there being a boy after you find out about a girl are 1/3, purely because you don't know whether you found out about an older or younger girl. Probability is just a function of our ignorance (at least in this case; I'm not qualified to have an opinion about whether it always is).

[Edit: Hm. Looking again, it seems Jeff Atwood's code is for a different problem he was also discussing, so nevermind. After considering your update, I think you might be right.]

[Further edit follows:]

Here's some python that essentially shows you're correct, unless I flubbed it:

    firstpickwasboy = {'boy':0, 'girl':0}
    firstpickwasgirl = {'boy':0, 'girl':0}
    
    choices = ['boy', 'girl']
    
    for i in range(100000):
      children = [random.choice(choices), random.choice(choices)]
      whichchild = random.randint(0, 1)
      otherchild = 1
      if(whichchild):  otherchild = 0
      if(children[whichchild]=='boy'):
        firstpickwasboy[children[otherchild]] += 1
      else:
        firstpickwasgirl[children[otherchild]] += 1
    
    >>> firstpickwasboy
    {'boy': 25132, 'girl': 25116}
    >>> firstpickwasgirl
    {'boy': 24679, 'girl': 25073}


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: