📜 ⬆️ ⬇️

Dozen of logical tasks with interviews

image

I do not know about you, but my favorite part of the interview is logical tasks.
It was possible to pass a lot of interviews for a developer’s job, so a small collection was collected.
I want to share with you!

Some tasks are simpler and more widely known, others make you think hard.
I will not publish the answers so far, I hope you can solve everything yourself.
I propose to stretch your brain ...
')
1) The man built a house, all the walls of which look to the south. A bear climbed into his house. What color is a bear?

2) There are 12 coins on the table, one of which is fake. It differs from the rest only in mass. What is the minimum number of weighings on a pan scale that a fake coin can be detected?

3) In the first isolated room - three bulbs, in the second - three switches from each of them. It is allowed to arbitrarily pull the switches, but you can only go from the second room to the first one time. How to find out from which bulb each switch, if you can reach the ceiling with your hand?

4) Given two ropes and matches. Each of the ropes burns in 1 hour, but they burn unevenly, so it is impossible to know exactly which part of the rope will burn in what time. How to measure an interval of 45 minutes with these ropes?

5) Three drink dispensers were brought to the office. The first gives out tea, the second coffee, and the third in random way tea or coffee. A glass of any drink costs one coin. Each machine has a sticker with the name of the product it issues. It so happened that the factory confused the labels in places and on each machine turned out to be wrong. How many coins do you need to spend to figure out where the machine is?

6) There are two subscribers A and B, the postman C and an open safe with two locks. Each subscriber has a key from one of the locks. If you pass the key through the postman, he can make a duplicate. How to transfer a letter from one subscriber to another through the postman, so that he could not read it? How will the algorithm change if you make a small hole in the safe for letter attachment?

7) The traveler is in the forest at some random point. It is known that the forest area is S, and the form can be completely arbitrary, but there are no glades in the forest. Which trajectory does the traveler need to move in order to get out of the forest with the minimum length of the route?

8) The traveler traveled one kilometer to the south, then one kilometer to the west, and after one kilometer to the north and returned to the starting point. How many places are there on earth? Hint: more than one ...

9) There is a huge file of several gigabytes in which integers are written. You need to write to another file all these numbers in sorted order. How to do it effectively?

10) There is a huge file of several gigabytes in which integers are written. It is known that each number occurs twice, but there is a single number that occurs once. Suggest an efficient algorithm for finding this number. How will the algorithm change if each number occurs in the file an even number of times, and only one of them is an odd number of times?

11) There is a huge file in which all integers from the range from 1 to 10 ^ 9 are written in random order. That is, there are absolutely all numbers from this range in the file, and they are found only once. However, one number occurs twice. How to find this number in an effective way?

12) How many ways can you decompose into 6 whole multipliers of 1 000 000?

PS Lovers of geometry for a snack euclidthegame.org

Source: https://habr.com/ru/post/230881/


All Articles