Check if someone has won tic-tac-toe

Problem Design an algorithm to figure out if someone has won in a game of tic-tac-toe. Solution I’ve written a game of tic-tac-toe in Java, and my current method of determining the end of the game accounts for the following possible scenarios for the game being over: The board is full, and no winner has yet been declared: Game is a draw. Cross has won. Circle has won. [Read More]

Sum of Hats

Problem There are 3 people Abel,Bill and Clark.Three of them have numbers written on their hats.One can only see the numbers written on others hats and can not see the number written on his own hat. Sum of numbers on any two 2 hats is equal to the number on the third hat.Now the following event occurs 1. Abel was asked about the number on his hat.He replied “Don’t Know” [Read More]

Wire Connections

Problem There are 66 wires connecting from the top floor to the ground floor. You can see the ends of the wires but you don’t know which one on the ground floor connects to which one on the top floor. You can tie the ends of several wires together and test the connections at the other end by using a bulb and battery. For example, if you first tie wires A, B, and C together at the ground floor and then go up to the top floor, you will figure out that the bulb will light if you put it between A and B, A and C, or B and C. [Read More]

OLD MONKS

Problem There are monks in a monastry who don’t speak(or communicate in any sense) with each other and have no have no mirrors or any reflective surface at their disposal. Evn the water they drink is from a “surahi” type pitcher(the opening is narrow and no reflection can be seen) and the floor is of extremely porous clay so that if u drop water to see reflection, the ground soaks it up so fast that it won’t work. [Read More]

Handshakes at Party

Problem I was at a party with MS one evening where he got bored and started keeping track of the number of handshakes made by people. A person was called “odd person” if he made an odd number of handshakes, otherwise he was called “even person”. After some time MS said to me, “Hey AD, do you know that there are an even number of odd persons?” I replied, “Big deal, MS. [Read More]

THE DEVIL & COLORED HATS

100 people find themselves at the gates of hell. The devil tells them that they’ll have a chance to go to heaven instead, but first they’ll have to play a game. The devil is going to line them all up in a straight queue, each person facing the back of the next person in line. The order of people in this line will be randomly chosen when the game starts. [Read More]

Black and white hats - Who knows what he is wearing

There are four man standing in front of a firing-squad. Two of them (nr.1 & 3) wear a black hat and two of them (nr.2 & 4) wear a white hat. They are all facing the same direction and between nr.3 and nr.4 stands a brick wall (see picture). So nr.1 can see nr.2 & 3, nr.2 sees nr.3, nr.3 sees only the wall and nr.4 doesn’t see a thing. The men know that there are two white and two black hats. [Read More]

Prisoners and Boxes

You are the janitor at a prison with 100 prisoners locked in separate, soundproof and windowless cells. You watch one day as the warden brings the prisoners out to a central room where there are 100 boxes laid out, labeled 1 through 100. He hands each prisoner a slip of paper and a pen, and asks everyone to write their name on their slip and hand it back to him. All the prisoner’s have different names. [Read More]