Checking For Bull Cows Function

Got it working a bit differently. :slight_smile:

void UBullCowCartridge::CheckBullCows(const FString& Guess, int32& BullCount, int32& CowCount) const
{
    BullCount = 0;
    CowCount = 0;

    for (int i = 0; i < Guess.Len(); ++i)
    {
        for (int j = 0; j < HiddenWord.Len(); ++j)
        {
            if (Guess[i] == HiddenWord[j])
            {
                if (i == j)
                    BullCount++;
                else
                    CowCount++;
            }
        }
    }
}
1 Like

Nice job getting it to work differently. You are on your way to being a successful programmer.

Privacy & Terms