I am reluctant to answer with code, but it seems that the community decided that was an appropriate question for Biology.SE. So here is my solution.
The idea is to "compress" the two bit that represent each nucleotide, such that each nucleotide will contribute 0 or 1 (not more) to the distance.
You could use binary operations to do something like this (in Java, but you can apply the logic in any language):
int seq1 = 54, seq2 = 194;//ATGC and TAAC
int evenBit = 0xAAAAAAAA, oddBit = 0x55555555;
int pseudoDist = seq1 ^ seq2; //Integer.bitCount(pseudoDist) is 5
int dist = ( (pseudoDist&evenBit)>>1 ) | (pseudoDist&oddBit);
int finalDist = Integer.bitCount(dist);//output 3 not five
The idea is to get the total number of bits that are different with:
seq1 ^ seq2
But you can't just count the bits yet, because you will get the hamming distance instead, so you have to compress all the bits that correspond to the same nucleotide to the same bit using:
pseudoDist&0x55555555. The first one keeps the bits on even positions and the second the ones on odd positions.
Now you use
evenBits | oddBits, and you can count the bits.