1.
Introduction
2.
Problem Statement
3.
Solution
4.
4.1.
How to master the Puzzle questions?
4.2.
Why are puzzles important in interviews?
4.3.
How to answer the puzzle questions in an interview?
4.4.
Is it common for puzzles to be asked in interviews?
4.5.
What exactly are puzzle questions?
5.
Conclusion
Last Updated: Mar 27, 2024

# Gates of Heaven

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

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

Ninja dies and reaches the gate of heaven. He has three doors in front of him out of which only one of them leads to heaven.

Out of the other two gates, one leads to hell for one day and then back to the gate and one leads to hell for two days and then back to the gate.

If he chooses one of these three gates, the gates are shuffled when he returns back.

How long is Ninja expected to take to reach heaven on average?

Output Format: Integer

Okay, let us now discuss the solution:

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

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

### How to master the Puzzle questions?

Understand all of the Terms given in 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.
Make use of what you know.
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.