Well if you write out all the possibilities, it would look like this:
AAB
ABB
ABA
BBA
BAB
BAA
^ That is just assuming that you can't do BBB & AAA.
With that, the probability of getting ABA is 1/6 because there are 6 possibilities that the code could be but you are only looking for 1 of those.
Now if you can use BBB & AAA, it would be 1/8.