# A dozen logical tasks with interviews

I don’t know how it is with you, but my favorite part of the interview is logical tasks.
I had a lot of interviews on the vacancy of the developer, so I got a small collection.
I hasten to share with you!

Some tasks are simpler and more widely known, others make you think hard.
I won’t publish the answers so far, I hope you can decide everything yourself.
I propose to stretch my brain ...

1) A man built a house, all of whose walls face south. A bear climbed into his house. What color is the bear?

2) There are 12 coins on the table, one of which is false. It differs from the rest only in mass. For what minimum number of weighings on a cup scale can a counterfeit be found?

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

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

5) Three vending machines with drinks were brought to the office. The first gives tea, the second coffee, and the third randomly tea or coffee. A glass of any drink costs one coin. Each machine has a sticker with the name of the product that it issues. It so happened that the labels were mixed up at the factory and each machine turned out to be wrong. How many coins do you need to spend to find out where is which machine?

6) There are two subscribers A and B, postman C and an open safe with two locks. Each subscriber has a key to one of the locks. If you pass the key through the postman, then 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 embedding letters?

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

8) The traveler walked one kilometer south, then one kilometer west, and then one kilometer 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 to find this number. How will the algorithm change if each number appears in the file an even number of times, and the 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, the file contains absolutely all numbers from this range, and they are found only once. However, one number occurs twice. How to find this number in an effective way?

12) In how many ways can one factor out 1,000,000 into 6 integers?

PS Geometry lovers for a snack euclidthegame.org