Assumption: Shifty coin only switches if weighed.
I believe this is optimal solution;
if (case 1)
otherwise (case 2)
If it is Case 1;
if (Case 1.1 - They are equal)
if (Case 1.2 - They are not equal)
if Case 2 happens (no balance at first weighing);
if there is balance (Case 2.1), (also meaning it was heavier at first)
if no balance again as ...
With the conditions stated in the problem, you cannot possibly find the shifty coin in less than
This is because
This means that
Since you can't do better than what I've stated, it's easy to find a solution, there are many permutations, here's an example: