{"id":375,"date":"2010-03-12T17:14:45","date_gmt":"2010-03-12T21:14:45","guid":{"rendered":"http:\/\/mattfife.net\/wordpress\/?p=375"},"modified":"2010-03-12T17:14:45","modified_gmt":"2010-03-12T21:14:45","slug":"question","status":"publish","type":"post","link":"https:\/\/mattfife.com\/?p=375","title":{"rendered":"Google interview question"},"content":{"rendered":"<p>In a certain country, a family continues to have children until they get a boy.\u00a0 When they get a boy, they have to stop having children. \u00a0 Otherwise, they keep going.\u00a0 Assuming there is always a 50\/50 chance of a boy\/girl when having any one kid and nobody stops &#8216;early&#8217; &#8211; what&#8217;s the ratio of males to females in such a society?<\/p>\n<p><strong>Answer(spoilers):<\/strong><br \/>\nAt first your gut tells you there needs to be more females than males &#8211; after all, there&#8217;s going to be families out there with 2,3,4,5 or even more girls.\u00a0 Yet only 1 boy.\u00a0 However, if you start thinking about it this way, a shocking revelation comes:<\/p>\n<p>A families first birth:<br \/>\n1\/2 = boys -&gt; they stop here, no girls at ALL in 1\/2 the households<br \/>\n1\/2 = girls -&gt; they go on&#8230;.<\/p>\n<p>2nd birth for those families with one girl:<br \/>\n1\/2 = boys -&gt; they stop with 1 girl, and 1 boy<br \/>\n1\/2 = girls -&gt; they go on&#8230;.<\/p>\n<p>so now it becomes a sum of:<br \/>\nboys = 1\/2 + (1\/2)*(1\/2)+ (1\/2)*(1\/2)*(1\/2) + (1\/2)*(1\/2)*(1\/2)&#8230;.<br \/>\ngirls = 1\/2 + (1\/2)*(1\/2) + (1\/2)*(1\/2)*(1\/2) + (1\/2)*(1\/2)*(1\/2)&#8230;<\/p>\n<p>Whaaaa?? &#8211; its the SAME.\u00a0 Yep &#8211; the count of the number of boys and girls will be the same.\u00a0 See, we forget that 1\/2 of the families will have NO girls at all &#8211; and that&#8217;s a big smack to the overall number of girls.\u00a0 Sure, there may be families with 2,3,4 or more girls, but always one boy &#8211; and that combined with the fact half the population&#8217;s families will only have a single boys child equals out.\u00a0 Crazy but true.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a certain country, a family continues to have children until they get a boy.\u00a0 When they get a boy, they have to stop having children. \u00a0 Otherwise, they keep going.\u00a0 Assuming there is always a 50\/50 chance of a boy\/girl when having any one kid and nobody stops &#8216;early&#8217; &#8211; what&#8217;s the ratio of males to females in such a society? Answer(spoilers): At first your gut tells you there needs to be more females than males &#8211; after all,&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/mattfife.com\/?p=375\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-375","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s4WECr-question","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=375"}],"version-history":[{"count":0,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/375\/revisions"}],"wp:attachment":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}