I am trying to calculate the various combinations that you could have. Matched, Not-Matched, Not-In. I had the function:
Code:
//Local variables
int w = 0;
char x[4]; //szMatch is users choice
char y[4]; //total is computers choice
CString matches="";
//Get an array of the colors to check each letter for a match
while(w<4)
{
x[w]=szMatch.GetAt(w); //Sets x[w] with users choice colors
y[w]=total.GetAt(w); //Sets y[w] with computers choice colors
w++;
}
//reset w to zero so we can use it again
w=0;
while(w<4){
if(x[w]==y[w]) //We have a match
matches=matches+"I ";
else if(x[w]==y[0]||x[w]==y[1]||x[w]==y[2]||x[w]==y[3]) //Not a match, but in the combo
matches=matches+"O ";
else //Default, no match
matches=matches+"X ";
w++;}
But when you pick say: Blue Blue Blue Blue, and Blue is only in the first match, the other 3 Blue's say that they are Not a match, but in the combo. This is confusing to people who do not expect that. So I tried to write another fucton for this and it was getting very long using if/else so I scrapped that idea.
Anyone have a better way to do this?