Oh, you must have heard of this problem for a million times by now. There are twelve coins, one of which is counterfeit, and the rest are genuine and identical. The only difference between the counterfeit coin and a genuine coin is in the weight, and the only tool you are given is a balance. Isolate the counterfeit coin and determine whether it is heavier or lighter than a genuine coin, using the balance for no more than three times.
And you must have heard of or thought of a rough strategy for solving this problem and discussed it with your friends. So you have talked the talk; now it is time to walk the walk. Write a program to isolate the counterfeit coin and determine whether it is heavier or lighter than a genuine coin.