Puzzles for software engineers is an effective way of judging their knowledge, expertise, and skills in their domain. As a software engineer, you should be prepared that you might be asked to solve different puzzles during the interview.
The hiring managers want to look at your problem solving skills. They pay attention to the approach you use to solve the puzzle and the answer you find.
In this article, you will learn about the commonly asked interview puzzles for software engineers, in addition to some coding puzzles. We also highlight tips that can help you solve these puzzles and ace the interview.
Top 20 Puzzle Questions Asked in Interviews
Most of the puzzles asked in interviews are meant to test how well you can think "different". They usually don't have one correct answer to refer to. You can solve it using your logic.
So, looking at 100s of interview puzzles for software engineers online and checking their answers won't be enough. You need to think on your own and develop an approach to solving these puzzles.
The following are 20 sample puzzles to get your prep started.
Common Puzzle Questions
Common interview puzzles for software engineers are those where you might not require your programming skills. It's based on your reasoning and logical skills.
Let's look at some common interview puzzles for software engineers.
1. Crossing the Bridge Puzzle
Four people need to cross a bridge. It's night-time and pretty dark. It's dangerous to cross the bridge without a flashlight, and there is only one flashlight. The bridge can only support two people at a time. Each person will take a different amount of time to cross the bridge: 1 min, 2 mins, 7 mins, and 10 mins. What is the shortest possible time for all four people to cross the bridge?
![Crossing the Bridge Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c37426dcba19e62d3f772_vOzfpqIu0-u4M3NxfIHSMn3x39jTZSQQi9qbi4rPbL_YSFdOZwJlKKGIUK5PLhtLbgR5ZNi09_EmHVIzyJDgKcu2_6sqEfOgMS0pjsmbX1IjyoV2I1_hW_WAuX3-WRlWAMjuv7sgaDGEK58ezbrEzT-nCBshTeSK.png)
2. The Man in the Elevator Puzzle
A man who lives on the tenth floor of a building takes the elevator every day to go down to the ground floor to go to work or to go shopping. When he returns in the evening, he takes the elevator to the seventh floor and walks up the stairs to the tenth floor to reach his apartment. Why does he do this? Note that if it's a rainy day, or if there are other people in the elevator, he goes to his floor directly. Also, he hates walking.
![The Man in the Elevator Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c377940c7e897dd00f874_Ek13-avorvbLVRfJ7wWv97gVbKLv3ohujy7n5iBgHGfYDhmPsHaY5JrtXsKT-ch-6xcDvc3kon7BDU9e5Q2u3EXI90yhWV1IK5scx5IgUPIs2dcZv6_g0gMTPi1WeGpyZJfA9JvYFGQW1zOLb76fwvT7eGT4wle-.png)
3. Heaven or Hell Puzzle
You have two doors in front of you. One door leads to heaven, and the other to hell. There are two guards, one by each door. One guard always tells the truth, and the other always lies, but you don't know who is who. You can only ask one question to one guard to find the door to heaven. What question would you ask?
![Heaven or Hell Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c3796cd0a8182056f785a_CAHovsqWBABiPL3NW_eI6dd2j18oHweChW5FjlxVz_IfzjbGMrHY7h-Y5HCafRlFwdGTbYjgv5ODv71PAPptdbnXDpx0qtptJr3qs4wuSbX4KvXwiGMzLR05_2sTxkJC35vQWNQav6vI4qBoUrM4sB-cO0DZuFho.png)
4. Three Mislabeled Jars
You have three mislabeled jars. The first jar contains apples, the second contains oranges, and the third contains a mix of apples and oranges. You need to label the jars. You can pick as many fruits as you want from each jar. What is the least number of fruits you have to pick from each jar to label them correctly?
![Three Mislabeled Jars](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c37c73b29c6f15b77ee0f_pilu7KFSHn4FkTMOQZNbxRb5LA14AJkusZrG7wNikAj-fIO0Zf9MQptAZg1uqOQHSprL5B9ZLqerABJ4-dIj7_o3slzSnvNGQySeCfC5F_8AYST9qKhXdEi_aniEl3-M2Hdn8zFuQSsyNtHThOyNQsQVLqwX4aG8.png)
5. Gold Bar Cut Puzzle
You have hired someone to work for you for seven days, and you have a gold bar to pay him. You must give him a piece of gold every day. What is the least number of cuts you can make to the gold bar such that you can pay them 1/7th of it each day?
![Gold Bar Cut Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c37e13d6ac91622909dea_MhN7upHJx_IBxscbY70wXmN24bG3wPAtkKtNYsgOGj-aKdlalHISQeqnq65M095T0QpQciyKEFTmFXLlBDKDz1aMBZLBqrkiOib2xKtNyMvCJKETrWUhwm-VwYPyaprQqTttYNYhdq2OUUMaTv0YQyp3xsUCPH75.png)
6. Man Fell in Well Puzzle
A man fell in a well. The well is 30 meters deep. In a day, he can climb 4 meters, but he slips down 3 meters. How many days would he take to come out of the well?
![Man Fell in Well Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c4dd00a1a9aef7ac6f95a_4dsfz53y4pf4QM9IwfvBieDaIGWLcE8p_qsiJNTBvCOQvirOH5HRmqZo08ElDPTeO8_kXXvXbOKScslTBiSBL9bBYK5SG7etm4wBukoddqxDibdgPIhTQBpYfK4_9Y_y5pOHl7iBu3aSTNR4EriGEyPS0CUfE_en.png)
7. Bag of Coins Puzzle
You have 10 bags full of infinite coins. But one bag is full of fake coins, and you can?t remember which one. You know that a genuine coin weighs 1 gram, and a fake coin weighs 1.1 grams. How do you identify the bag containing forged coins in minimum readings?
![Bag of Coins Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c4d9e3107e3d11435e900_yByJfyXvrKrs16DPqfwSowGRZV2AlJb8QOtTZ_nZ0hnlyDz3aVLlYig0n-XfA3G53Ky7Xb6hpY3w0y8fOkJJoVww0M7mV-jdVky4EatY1Qn3-6HDMTypw-qcSxJfhQDtlye40vlrVguaq95Wc-lG8HtFK82hKUYf.png)
8. Horses on a Race Track Puzzle
There are 25 horses and five race tracks. Find the fastest three horses among the 25 in the least number of races.
![Horses on a Race Track Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c4d73c6ae9e5e7aa12356_6D5Jdwl6cBG7dR7MqfvU3wDUJuC9PN7SnU3Pv2zyv_4jv2Y74o0M5aLI_7Kz_bJsRng01q45n_Qn71wL_TqXNw9kNqfFFoLzKnf-o4SXU-3jClQLeLBbRrEc2BSZB3-bnM4NrjLC9xZVdi94lCzBcnp53Qb0JILR.png)
9. Batteries Puzzle
There are eight batteries, but only four of them work. You have to use them for a flashlight, which needs two working batteries. What is the minimum number of battery pairs you need to test to ensure that the flashlight is turned on?
![Batteries Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c4d3952675fc3ea901f91_JvHXy9vHw3it-tozzwdTG21p1yIWKhhLDPbOO6zLGWGPuNyBMsTP4q0YE1ykGph1NaWgTzs-co7Y-nf_Eiw5pRUsoKWepUYvVyXkGNRPqY5GnV0-VGsLM6S9y3X42ha6C_ndYMECO7wTgAv21PclVG3xRRq9GBId.png)
10. Birthday Cake Puzzle
A birthday cake has to be cut into eight equal pieces in exactly three cuts. Find a way to make this cut possible.
![Birthday Cake Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c4d09f7a63390dbb442d5_puAbjG1ztxeHn2gQPXhQeNoMFj6dN1-x-3Rko68mP7RK47-XG8RKXJTiXU61wdSyZQ4NJLB6iN5turk3rZM1f_xDPnargxRMSkdr4NwTSjiYJeVKkyf0fvRWy9MdYkjYhn9W8Nl40jHEWDODKnMC5OMZim9pXTun.png)
11. Clock Angle Puzzle
If the time is 3:15 when you look at a clock, what is the angle between the hour hand and the minute hand?
![Clock Angle Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c3b537e20b3a25827ef7c_rEX9dc-sZzWrgWBdksNIg6RKU3FGtQiIqy4_x7uPdXWAV8_ad59UMEQvL_2NpcuuChSPbb1kxZmTOdwfQqdkBUg4uVPrBkx9tTS8bqqXh6LKVf0uTKchOJBDQwRkDnLF15NNw_GjDY6cw5GXZOdMhoK5wVQMUUj6.png)
12. Tomato Soup Puzzle
You have a glass of tomato soup. You have one other empty glass of a different size and shape. You have to give the soup to two children. How would you divide the soup into two glasses so that both of them are satisfied that they have an equal share of the soup?
![Tomato Soup Puzzle](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c39ccbe88ed34abd3f6d6_zNynT9xz4BK0yZEAn6PUWkw2oseRMaC97gwJxky7JlingkKF5ncke7t2C58cGFVPikRudTPpP5RsoY83dkUQ045n9PZ3da8xeogE75T4XGVAV9DE6SZWpPm7VkWHNqOk2n3Ahg5LVkFyNl_2M6Ew9bm7RpImMTtm.png)
Coding Puzzle Questions
Coding interview puzzles for software engineers are those types of puzzles where you have to use a programming language to solve. them. Let's look at some coding puzzles asked in interviews.
1. Addition Puzzle
Add two numbers without using the addition operator.
2. Determine the If Condition Puzzle
What should be the 'if' condition in the following code snippet to print?Hello World??
if "condition"
printf ("Hello");
Else
printf("World");
3. Swap 2 Numbers Puzzle
Swap 2 numbers without using a third variable.
4. Print Numbers From 1 to N Puzzle
Print numbers from 1 to N without using any looping construct.
5. Print Semicolon Puzzle
Print a semicolon without using a semicolon in the program
6. Equal Integers Puzzle
Determine if 2 integers are equal without using comparison and arithmetic operators.
7. Minimum Number Puzzle
Given 2 numbers. Find the minimum number without using conditional statements or ternary operators.
8. Spotting a Truck Puzzle
The probability of spotting a truck on a highway in an hour is 0.999. What is the probability of spotting a track on that highway in 20 minutes?
3 Key Tips to Solve Puzzle Problems in Interviews
Yes, these puzzles are tricky. Following are 3 key tips that will ensure that you will not stumble during the interview:
![Tips to Solve Puzzle Problems in Interviews](https://cdn.prod.website-files.com/5d0dc87aac109e1ffdbe379c/650c399a7e02d53205adc27d_UkGciDLxcWxJgnKpFHFodalfbn7vEqu0WZwy12svUCyX5RFqslyaDZlnDZdLPVPO668jAaP5ER3bTDw5SoBVDAP0DFSaxWgABzMGx84EPk2oCQJRQpHAPfxcI8oOi2rlPkK2HgwguVhX4qu0W-eOuDJUR8mIadbo.png)
1. Clarify everything before you start
Don't jump into the solution, and do not make any assumptions. If any information seems missing, ask and clarify.
2. Explain your process
While solving the puzzle, explain your thought process to the interviewer. It allows your interviewer to see how you plan, think, reason, and solve complex problems under pressure. Always remember - these puzzles are more about showcasing your analytical skills than finding the right solution.
3. Provide one or more solutions to the puzzle
Use your reasoning and logical skills to deduce a solution to the puzzle, even if it's not the correct solution. You can also discuss alternate methods. It's more about your reasoning and deducing the solution, than finding the right solution.
Nail the Engineering Manager Interview with Interview Kickstart!
With increasing competition in the software engineering domain, acing the interviews is the key step to landing your dream role. Join Interview Kickstart's Engineering Manager Interview Masterclass to learn the commonly asked interview puzzles and concepts. You will also learn the key concepts of data structures & algorithms and system design.
Our expert instructors will teach you how to write an ATS-clearing resume, optimize your LinkedIn profile, and build a strong online personal brand.
We have helped numerous tech aspirants to land their dream jobs. Read their success stories to understand how we have helped them.
FAQs on Puzzles for Software Engineers
1. Why are Puzzles Used in Software Engineering Interviews?
Puzzles are used to test a candidate's lateral thinking, problem-solving, and creative thinking skills. They help interviewers assess how well candidates can handle real-world problems, think critically, and come up with efficient solutions.
2. Do Puzzles Have Multiple Solutions?
Yes, many puzzles have multiple solutions. The goal is often to see how you approach and solve the problem rather than finding the one "correct" answer.
3. Are Coding Puzzles Different From Common Puzzles?
Yes, coding puzzles require programming skills to solve, whereas common puzzles focus on logical reasoning and problem-solving without needing coding.
4. How Should I Approach Solving a Puzzle During an Interview?
First, clarify any doubts and ensure you understand the problem fully. Then, explain your thought process aloud as you work towards a solution. This helps the interviewer see how you think and approach problem-solving.
5. What if I can't Find the Correct Solution to a Puzzle?
It's important to demonstrate your reasoning and logical skills. Even if you don't find the exact solution, discussing your approach and possible alternative solutions can still showcase your problem-solving abilities.
Related reads: