Riddle #684


Six glasses in a row

Six glasses are in a row. The first three are filled with milk and the last three are empty. By moving only one glass, can you arrange them so that the full and the empty glasses alternate?
93.39 %
38 votes

Similar riddles

See also best riddles or new riddles.


Anagram Checker

Two words are anagrams if and only if they contain the exact same letters with the exact same frequency (for example, "name" and "mean" are anagrams, but "red" and "deer" are not). Given two strings S1 and S2, which each only contain the lowercase letters a through z, write a program to determine if S1 and S2 are anagrams. The program must have a running time of O(n + m), where n and m are the lengths of S1 and S2, respectively, and it must have O(1) (constant) space usage.
First create an array A of length 26, representing the counts of each letter of the alphabet, with each value initialized to 0. Iterate through each character in S1 and add 1 to the corresponding entry in A. Once this iteration is complete, A will contain the counts for the letters in S1. Then, iterate through each character in S2, and subtract 1 from each corresponding entry in A. Now, if the each entry in A is 0, then S1 and S2 are anagrams; otherwise, S1 and S2 aren't anagrams. Here is pseudocode for the procedure that was described: def areAnagrams(S1, S2) A = new Array(26) A.initializeValues(0) for each character in S1 arrayIndex = mapCharacterToNumber(character) //maps "a" to 0, "b" to 1, "c" to 2, etc... A[arrayIndex] += 1 end for each character in S2 arrayIndex = mapCharacterToNumber(character) A[arrayIndex] -= 1 end for (i = 0; i < 26; i++) if A[i] != 0 return false end end return true end
93.55 %
39 votes


Headwaiter in a restaurant

Betty signals to the headwaiter in a restaurant, and says, ''There is a fly in my tea.'' The waiter says ''No problem Madam. I will bring you a fresh cup of tea.'' A few minutes later Betty shouts, ''Get me the manager! This is the same cup of tea.'' How did she know? Hint: The tea is still hot.
Betty had already put sugar in her tea before sending it back. When the "new" cup came, it was already tasted sweet.
93.39 %
38 votes


To sentries

Two sentries were on duty outside a barracks. One faced up the road to watch for anyone approaching from the North. The other looked down the road to see if anyone was approached from the South. Suddenly one of them said to the other, "Why are you smiling?" How did he know that his companion was smiling?
Although the guards were looking in opposite directions, they were not back to back. They were facing each other.
89.58 %
40 votes


Difficult pop quiz

A teacher decides to give a pop quiz one day but all of her students refuse to take the quiz thinking that the teacher will call off the quiz. She can give only one of these students a detention for skipping the quiz. All of the students know each other’s names and if a student knows he/she is getting a detention they take the quiz. How can she threaten her students with the single detention so they all take the quiz?
She tells them that she will give the student who skips the quiz whose name comes first alphabetically a detention. This student won’t skip because they know they are getting a detention if they do. The next person alphabetically will then know that they will get a detention so they won’t skip either, and so on.
89.81 %
41 votes


Leave 6

Take 9 from 6, 10 from 9, 50 from 40 and leave 6. How is it possible?
SIX - 9 (IX) = S 9 (IX) - 10 (X) = I 40 (XL) - 50 (L) = X
93.39 %
38 votes


Lost jewelry

A couple went on holiday for three weeks. They carefully locked their house, and had a neighbor check on the place while they were gone. When they returned, the wife was distressed to lean that because of a power failure she had lost all her fine jewelry. She had hidden the jewelry in what she thought was a very safe place. She was not robbed. Her jewelry was lost by accident. Why?
In this true incident, the wife had hidden her best jewelry inside her freezer in a bag among all the frozen food. Because of a general power failure the freezer had gone off. A friendly neighbour (who had a key in order to water the plants) had tried to be helpful by throwing out all the bad food - and with it went the jewelry.
80.52 %
49 votes


Ant and Triangle Problem

Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide?
So let’s think this through. The ants can only avoid a collision if they all decide to move in the same direction (either clockwise or anti-clockwise). If the ants do not pick the same direction, there will definitely be a collision. Each ant has the option to either move clockwise or anti-clockwise. There is a one in two chance that an ant decides to pick a particular direction. Using simple probability calculations, we can determine the probability of no collision. P(No collision) = P(All ants go in a clockwise direction) + P( All ants go in an anti-clockwise direction) = 0.5 * 0.5 * 0.5 + 0.5 * 0.5 * 0.5 = 0.25
86.00 %
40 votes


The Miller's Daughter

A poor miller living with his daughter comes onto hard times and is not able to pay his rent. His evil landlord threatens to evict them unless the daughter marries him. The daughter, not wanting to marry the landlord but fearing that her father won't be able to take being evicted, suggests the following proposition to the landlord. He will put two stones, one white and one black, into a bag in front of the rest of the townspeople. She will pick one stone out of the bag. If she picks the white stone, the landlord will forgive their debt and let them stay, but if she picks the black stone, she will marry the landlord, and her father will be evicted anyway. The landlord agrees to the proposal. Everybody meets in the center of the town. The landlord picks up two stones to put in the bag, but the daughter notices that he secretly picked two black stones. She is about to reveal his deception but realizes that this would embarrass him in front of the townspeople, and he would evict them. She quickly comes up with another plan. What can she do that will allow the landlord save face, while also ensuring that she and her father can stay and that she won't have to marry the landlord?
The daughter picks a stone out, keeps it in her closed hand, and proclaims "this is my stone." She then throws it to the ground, and says "look at the other stone in the bag, and if it's black, that means I picked the white stone." The landlord will reveal the other stone, which is obviously black, and the daughter will have succeeded. The landlord was never revealed as a cheater and thus was able to save face.
92.14 %
54 votes


Akbar and Birbal

One day, Emperor Akbar posed a question to Birbal. He asked him what Birbal would choose if he offered either justice or a gold coin. "The gold coin," said Birbal without hesitation. On hearing this, Akbar was taken aback. "You would prefer a gold coin to justice?" he asked, not believing his own ears. "Yes," said Birbal. The other courtiers were amazed by Birbal's display of idiocy. They were full of glee that Birbal had finally managed himself to do what these courtiers had not been able to do for a long time - discredit Birbal in the emperor's eyes! "I would have been disappointed if this was the choice made even by my lowliest of servants," continued the emperor. "But coming from you it's not only disappointing, but shocking and sad. I did not know you were so debased!" How did Birbal justify his answer to the enraged and hurt Emperor?
"One asks for what one does not have, Your Majesty." said Birbal, smiling gently and in quiet tones. "Under Your Majesty´s rule, justice is available to everybody. But I am a spendthrift and always short of money and therefore I said I would choose the gold coin." The answer immensely pleased the emperor and respect for Birbal was once again restored in the emperor's eyes.
93.39 %
38 votes


A millionaire

A kind hearted person Mr. Rawat buy packed food at 3$/packet from United states and sells them at 1$/packet at Africa. After some time he becomes a millionaire. How come the guy become millionaire?
He started out as a billionaire, but lost so much money in his good works (by giving to poor people) that he became a millionaire.
83.96 %
52 votes