Here is mi Count Bulls and Cows function definition using the Contians function of FString
/**
* \brief Counts howmany Bulls and Cows has the guess word
* \param Guess The guess word to search for Bull and Cows
* \param Isogram The isogram word to compare
* \return A binary tuple of int32 where the first value are Bulls and second are Cows conts
*/
TTuple<int32, int32> UBullCowCartridge::CountBullsAndCows(const FString& Guess, const FString& Isogram)
{
auto Bulls = 0;
auto Cows = 0;
for (auto GuessIndex = 0; GuessIndex < Isogram.Len(); GuessIndex++)
{
const TCHAR ISOLatter = Isogram[GuessIndex];
const TCHAR GuessLetter = Guess[GuessIndex];
if (GuessLetter == ISOLatter)
{
++Bulls;
}
else if (Isogram.Contains(GuessLetter + ""))
{
++Cows;
}
}
return MakeTuple(Bulls, Cows);
}