## Solution

Suppose the average days spent is X.

=> â…“ of the cases he reaches heaven in zero days. ( â…“ * 0)

=> â…“ of the cases it takes ( 1 + X). ( â…“ * (1+X))

=> â…“ it takes ( 2+X) days. ( â…“ * (2+X))

The probability of choosing any of the three cases is â…“. To find the average time, we need to take all the cases into consideration.

X = â…“ * 0 + â…“ * (1+X) + â…“ * (2+X)

X = 0 + â…“ + X/3 + â…” + X/3

X = (2X + 3)/3

3X = 2X + 3

**X = 3 **

**Hence, on average it will take 3 days to reach out to heaven.**

Let us now discuss the FAQs related to puzzle questions:

Check out this problem - __Check If A String Is Palindrome__

## Frequently Asked Questions

### How to master the Puzzle questions?

Understand all of the Terms given in the question.

Take your time reading the question.

Make a list of all the possibilities.

Visualize the problem statement using pen and paper.

Practice daily to enhance your problem-solving techniques.

### Why are puzzles important in interviews?

In software engineer interviews, puzzles are a realistic way to test your lateral thinking. It demonstrates to the interviewer your ability to solve real-world problems and think creatively.

### How to answer the puzzle questions in an interview?

Consider the problem.

Ask for clarification.

Make use of what you know.

Describe your reasoning.

Provide a solution.

### Is it common for puzzles to be asked in interviews?

The majority of the puzzles asked in interviews are designed to assess your ability to think "differently." They rarely have a single correct answer to which they can refer. You can use your own logic to solve it. So looking at hundreds of puzzles online and double-checking their solutions isn't going to cut it.

### What exactly are puzzle questions?

This type of question consists of items belonging to different groups or possessing different qualities being given along with some clues with which the candidate is required to group and analyze the given items and answer the questions accordingly.

## Conclusion

In this article, we discussed the interview-based puzzle question - **Gates of Heaven** which is solved by taking all the cases into consideration.

**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, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Happy Learning!