Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Problem Statement
3.
Ratio of Boys and Girls Solution
4.
Frequently Asked Questions
4.1.
What is a puzzle?
4.2.
What are the advantages of solving puzzles?
4.3.
Why are puzzles asked in an interview?
4.4.
What are some tips for preparing for a puzzle interview?
4.5.
Name some common puzzles asked in the interview.
5.
Conclusion
Last Updated: Mar 27, 2024

Ratio of Boys and Girls

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @
Interview Puzzles

Introduction

Puzzles are good exercise for the brain. They help in enhancing the cognitive abilities of the brain helping with Problem Solving and related skills. There are numerous types of puzzles; each one having a logic inherent to itself which helps in cracking it. A good puzzle well is actually like a good mystery that we may have read about or watched on TV. It has the finest of hints which help in reaching its solution.

The following article discusses one such puzzle so let's get right to it.

Problem Statement

In a country where everyone wants a boy, each family continues having babies till they have a boy.

After a long time, what is the proportion of boys to girls in the country? (Assuming the probability of having a boy or a girl is the same)

Round off your answer to two decimal places and output the answer as I.xx where I is the integer part of your answer, and xx is the first two decimal places of the rounded-off answer.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Ratio of Boys and Girls Solution

Assume there is N number of couples, so there would be N boys. The number of girls can be calculated by the following method.

Number of girls = 0*(Probability of 0 girls) + 1*(Probability of 1 girl) + 2*(Probability of 2 girls) + …

Number of girls = 0*(N*1/2) + 1*(N*1/2*1/2) + 2*(N*1/2*1/2*1/2) + …

Number of girls = 0 + N/4 + 2*N/8 + 3*N/16 + …

Number of girls = N

Using mathematical formulas, it becomes apparent if you sum up the first 4-5 terms.

The proportion of boys to girls is 1:1.

As such, the answer would be 1.00.

Check out this problem - 8 Queens Problem

Frequently Asked Questions

What is a puzzle?

A puzzle is a game of words, toys, questions, etc. that helps in increasing our problem-solving ability.

What are the advantages of solving puzzles?

Solving puzzles enhance the problem-solving skills of a person. It also improves the logic building of a person.

Why are puzzles asked in an interview?

There are no such mandatory rules to ask puzzle or logical questions in IT interviews. But it's a regular habit of most the pro-interviewers to ask puzzles or logical questions, just to check the interviewee's presence of mind and problem-solving ability.

What are some tips for preparing for a puzzle interview?

Practice, always keep a pen and paper with you and elaborate your approach.

Name some common puzzles asked in the interview.

Crossing the bridge, Hand Shakes at the party, Bag of coins, Clock angle puzzle, Measuring time by burning ropes, and many more.

Conclusion

In this article, we discussed the interview-based puzzle. The puzzle is based on the ratio of boys and girls in a given town. We also discussed the solution to the given puzzle in the article above.

Recommended Readings:


For more information, refer to Free Interview Preparation resources.

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Interview Puzzles, Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Do upvote our blog to help other ninjas grow.

Happy Learning!

Live masterclass