Ben and other students,
I came up with a different solution that seems to return the correct number of cows and bulls. It depends on the Guess length being equal to the MyHiddenWord length, which we assumed. I didn’t test this too rigorously and it may turn out to be flawed. If so I will find out soon enough.
(Sorry, I thought the text would stay formatted. Here’s a screenshot for visual purposes: Imgur )
for (int32 i = 0; i < HiddenWordLength; i++)
{
if (MyHiddenWord[i] == Guess[i]) { BullCowCount.Bulls++; }
else
{
for (int32 j = 0; j < HiddenWordLength; j++)
{
if (MyHiddenWord[i] == Guess[j]) { BullCowCount.Cows++;}
}
}
}