Well, that solution appears solid, but here’s my method. We’ll say the coins are numbered 1-12.
First Weighing: 1 2 3 4 against 5 6 7 8. Note which side is heavier and which is lighter.
Second Weighing: 1 2 3 5 against 4 9 10 11. On this weighing, there are three possibilities: the scale tips the same way, the scale balances, or the scales tip in the opposite way.
If the scales tip the same way, that is, if the side with “1 2 3” remains heavy or light on this weighing, you know that the counterfeit is either 1, 2, or 3, and you’ll know whether it is heavy or light. For the final weighing, weigh 1 against 2. If the scales tip, you’ll know which is the counterfeit, because you already figured out if the counterfeit is heavy or light; if they don’t tip, you know the counterfeit is 3.
If the scales balance, you’ll know that the counterfeit is one of the coins you removed (6, 7, or 8), and you’ll know whether it is heavy or light from the first weighing. For the final weighing, weigh 6 against 7. If the scales tip, you’ll know which is the counterfeit, because you already figured out if the counterfeit is heavy or light; if they don’t tip, you know the counterfeit is 8.
If the scales tip in the opposite way, then the counterfeit must be either 4 or 5. Changing the positions of these two coins caused the scale to tip in the opposite way. For the final weighing, weigh 4 against 1, because you know that 1 is not the counterfeit. If the scales unbalance, 4 is the counterfeit; if they don’t, 5 is the counterfeit (you won’t have figured out if it’s light or heavy, but you didn’t have to in this scenario, and your task was to find the counterfeit, not to figure out if it’s lighter or heavier).
But what if the scales balance on the first weighing, but unbalance on the second? Then you know that the counterfeit is one of the coins you added (either 9, 10, or 11), and you’ll know whether it is heavy or light. For the final weighing, weigh 9 against 10. If the scales tip, you’ll know which is the counterfeit, because you already figured out if the counterfeit is heavy or light; if they don’t tip, you know the counterfeit is 11.
And there’s a final possibility: if the scales balance for both the first and second weighings, coin 12 is the counterfeit, and a third weighing isn’t even necessary. But for giggles, you can weigh it against one of the good coins and find out if it’s heavy or light.
The trick, I feel, is in the second step: taking a coin from one side and swapping it with a coin on the other. That fixes it so that by the final step, no matter what, you have it narrowed down to at most 3 coins.