In a parliament, there are 100 people, and some of these people are enemies with each other. Show that you can split the people into 2 groups so that each person has at least as many enemies in the opposite group as he has in his own.
SOLUTION
For each split of the people into 2 groups, compute the animosity level of each person by subtracting the number of enemies in the opposite group from the number of enemies in his own group. Then, split the people into 2 groups so that the total animosity level of all of them is as little as possible. If there is a person, who has more enemies in his own group than the opposite one, then by transferring him to the other group, we will reduce the total animosity level of the people and will get a contradiction.
An evil warden holds you as a prisoner but offers you a chance to escape. There are 3 doors A, B, and C. Two of the doors lead to freedom and the third door leads to lifetime imprisonment, but you do not which door is what type. You are allowed to point to a door and ask the warden a single yes-no question. If you point to a door that leads to freedom, the warden does answer your question truthfully. But if you point to the door that leads to imprisonment, the warden answers your question randomly, saying either “YES” or “NO” by chance. Can you figure out a way to escape the prison?
SOLUTION
You can point towards door A and ask whether door B leads to freedom. If the warden says “YES”, then you open door B. It can not lead to imprisonment because this would mean that door A leads to freedom and the warden must have told you the truth. If the warden says “NO”, then you open door C. This is because either the warden lied, and then the imprisonment door is A, or he told you the truth, and then the imprisonment door is B.
Somehow, you end up in a room that has three doors. Behind the first door, there is a deadly poisonous gas. Behind the second door, there are trained assassins with knives. Behind the third door, there are lions that have not eaten in years. Which door would you choose to open?
SOLUTION
You should open the door with the lions. If they have not eaten in years, they will be dead already.
Who says science jokes are not funny? Below you can see some of the best Programming jokes we know, along with short explanations to the more obscure of them.
Do you know any funny Programming jokes yourself? Let us know in the comments section below.
“What is the object-oriented way to become wealthy?” “Inheritance.”
Explanation Inheritance is one of the main mechanisms of object-oriented programming.
“Why did the programmer quit his job?” “Because he did not get arrays.”
Explanation Array is a data structure in programming. This is a wordplay with “a raise”.
“Why do programmers always mix up Halloween and Christmas?” “Because Oct 31 equals Dec 25.”
Explanation The number 31 in the Octal number system equals the number 25 in the Decimal number system.
“0 is False and 1 is True, correct?” “1.”
Explanation This answer does not give any information.
A man is smoking a cigarette and blowing smoke rings into the air. His girlfriend becomes irritated with the smoke and says, “Can’t you see the warning on the cigarette pack? Smoking is hazardous to your health!” To this, the man replies, “I am a programmer. We don’t worry about warnings; we only worry about errors.”
Explanation In programming, there are two types of problems with the code – warnings and errors. Warnings do not necessarily prevent the code from executing properly, so they are not that worrhsome.
Why computers are like men:
In order to get their attention, you have to turn them on.
They have a lot of data but are still clueless.
They are supposed to help you solve problems, but half the time they are the problem.
As soon as you commit to one, you realize that if you had waited a little longer, you could have had a better model.
Why computers are like women:
No one but the Creator understands their internal logic.
The native language they use to communicate with other computers is incomprehensible to everyone else.
Even your smallest mistakes are stored in long-term memory for later retrieval.
As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it.
“What do you call a programmer from Finland?” “Nerdic”.
Explanation This is a wordplay with the word nerdy and Nordic.
“Why do Java programmers need to wear glasses?” “Because they do not C#.”
Explanation Java and C# are two different programming languages.
99 little bugs in the code. 99 bugs in the code. Take one down, patch it around. 100 little bugs in the code.
Explanation This is a modification of the famous “99 bottles of beer”. In coding, it often happens that you fix one bug and then few others appear.
The programmer got stuck in the shower because the instructions on the shampoo said “Lather. Rinse. Repeat.”
Explanation The instructions created a loop without terminating conditions.
“I don’t see women as objects. I consider each of them in a class of her own.”
Explanation A joke related to object-oriented programming.
An SQL query walks into a bar, walks up to two tables and asks, “Can I join you?”
Explanation “SQL JOIN” is a clause which is used to combine two or more tables.
You and eight of your team members are trying to escape the Temple of Doom. You are running through a tunnel away from a deadly smoke and end up in a large hall. There are four paths ahead, and exactly one of them leads to the exit. It takes 20 minutes to explore any of the four paths one way, and your group has only 60 minutes until the deadly smoke suffocates you. The problem is that two of your friends are known to be delirious and it is possible that they do not tell the truth, but nobody knows which ones they are. How should you split the group and explore the tunnels, so that you have enough time to figure out which is the correct path and escape the temple?
SOLUTION
You explore the first path. You send two of your teammates to explore the second path. You send the remaining six teammates in groups of three to explore each of the two remaining paths. If your path leads to the exit, then everything is good. Otherwise, you ask the two groups of three whether their paths lead to the exit. If in both groups everyone answers consistently, then nobody is lying, and you will escape. If in both groups there is a person whose answer is different from the others in the group, then the majority in both groups says the truth. Once again, you will know which path leads to the exit. Finally, if in exactly one of the groups everyone answers consistently, you ask the group of two. If the team members there answer consistently with each other, then they say the truth. You will have two groups which tell the truth and will know which path leads to the exit. If the answers of the teammates in the group of two differ, then in the inconsistent group of three the majority will be saying the truth. Again, you will be able to deduce which path leads to the exit.
There is an island on a planet and infinitely many planes on it. You need to make one of these planes fly all around the world and land back to the island. However, each of the planes can carry fuel which is enough to travel just half of the way, and fuel cannot be stored anywhere on the planet, except for the island and in the planes. Assuming the planes can refuel each other mid-air, and all of them must eventually arrive safely back on the island, how many of them do you need to accomplish the task?
SOLUTION
3 planes are enough, label them A, B, C. They leave the island simultaneously in a clockwise direction, and after 1/8 of the way, A refuels B and C completely, then turns back towards the island. B and C continue to fly until they get to 1/4 of the way, where B refuels C completely and turns back towards the island. When C gets mid-way, A and B leave the island counter-clockwise, and after 1/8 of the way, A refuels B completely and turns back towards the island. B continues towards C, and when the two planes meet, they share their fuel, then fly together towards the island. In the meantime A arrives on the island, refuels completely, and starts flying again counter-clockwise towards B and C, so that it can meet them and give them enough fuel, so that all of them arrive safely on the island. It is easy to see that 2 planes are not enough.
You place two stones on a chessboard and start moving them one by one, every time shifting a stone to an adjacent cell – left, right, up, or down, without letting the stones at any time occupy the same cell. Is it possible to find such a sequence of moves, that all possible combinations for the position of the stones occur exactly once?
SOLUTION
No, such sequence does not exist. Call a position of the stones “matching” if the stones occupy cells of the same color, and “opposite” if the stones occupy cells of opposite colors. If such sequence exists, then the number of matching and opposite positions must differ by at most 1. However, the number of matching positions is 64×31, whereas the number of opposite positions is 64×32, so this is not true.