Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024

Cheryl’s Birthday Puzzle

Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM
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.

Puzzle Description

The puzzle is as follows:

Albert and Bernard just become friends with Cheryl, and they want to know when her birthday is. Cheryl gives them a list of 10 possible dates:

  • May 15, May 16, May 19
  • June 17, June 18
  • July 14, July 16
  • August 14, August 15, August 17

 

Cheryl then tells Albert and Bernard separately the month and the day of her birthday respectively.

Albert: I don't know when Cheryl's birthday is, but I know that Bernard doesn't know too. 

Bernard: At first I don't know when Cheryl's birthday is, but I know now.

Albert: Then I also know when Cheryl's birthday is.

So when is Cheryl's birthday?

Problem statement

Source

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

Solution

Cheryl gives Bernard and Albert a list of 10 possible dates for her birthday. 

May   15 16     19
June       17 18  
July 14   16      
August 14 15   17    

Our approach in this solution is to eliminate the impossible dates based on the conversation between Bernard and Albert. 

Albert: I don’t know when Cheryl’s birthday is, but I know that Bernard doesn’t know too.

Albert knows the month correctly, and Bernard knows the day. Bernard would have correctly known Cheryl’s birthday if the date was 18 or 19, as these dates occur only once. The fact that Albert knows that Bernard doesn’t know the birthday proves that the birthday is either in July or in August.

The remaining options are:

July 14   16  
August 14 15   17

Bernard: At first I didn’t know when Cheryl’s birthday is, but I know now.

After eliminating the choices, Bernard knows the birthday correctly. This is possible only if the day is either 15, 16, or 17, as these occur only once in the remaining options. If it would’ve been 14, Bernard could not guess the birthday correctly as it appears twice.

After eliminating the choices:

July   16  
August 15   17

Now, finally, Albert says:

Albert: Then I also know when Cheryl’s birthday is.

Looking at the remaining options, we can see that we have only August and July left, with August having two possible dates and July having only one possible date.

Albert said that he now knows when the birthday is. It is possible only if the month is July as August has two possible options. 

Therefore, the answer to this puzzle is July 16.

Answer: July 16

Frequently Asked Questions

What are some of the tips for solving puzzles during an interview?

Always ask for clarifications if you feel that you do not understand the puzzle entirely. Getting the right answer is not as important as your approach. Always explain your approach while answering.

Why are puzzles asked in interviews?

To check the analytical and problem-solving skills of the candidate.

Should we always reach the correct answer to the puzzle during the interview?

You should focus on your approach and your ability to convey it to the interviewer. Sometimes, you may not be able to reach the correct answer, but if your approach is right, it does not matter much.

Conclusion

This blog talked about a very interesting puzzle called Cheryl’s birthday puzzle. We looked at its solution extensively. This is just one of the numerous puzzles that can be asked in your interviews. You can solve any puzzle asked in your interview if you keep practicing these types of puzzles. 

Recommended Readings:


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 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.

Topics covered
1.
Introduction
2.
Puzzle Description
3.
Solution
4.
Frequently Asked Questions
4.1.
What are some of the tips for solving puzzles during an interview?
4.2.
Why are puzzles asked in interviews?
4.3.
Should we always reach the correct answer to the puzzle during the interview?
5.
Conclusion