To solve this coin puzzle, you can split the 12 coins into three groups of 4. First, compare two of the groups on the balance scale. If they balance, the counterfeit coin is in the third group. If they don't balance, you'll know which group contains the counterfeit coin.
Next, take the group with the potential counterfeit coins and split it into three groups of 1, 1, and 2. Put one coin from the group of 2 on each side of the balance scale. If they balance, the counterfeit coin is one of the single coins, and you can identify it with one more weigh.
If the scale tips, you've identified the group containing the counterfeit coin. Take the two remaining coins from that group, and weigh them against each other. The heavier one is the counterfeit coin if the previous weighing indicated it was heavier, or the lighter one if it was indicated as lighter.
In three weighings, you can find the counterfeit coin and determine whether it's lighter or heavier.