SubmitGuess function complete challenge in different way

Hello, I am new here and I am Enjoying this course.

I have a question related to the challenge.

I completed it as this:

FBullCowCount FBullCowGame::SubmitGuess(FString Guess){	
CurrentTry++;

FBullCowCount BullCowCount;

for (int32 i = 0; i < HiddenWord.length(); i++) 
{
	if (Guess[i] == HiddenWord[i])
	{
		BullCowCount.Bulls++;
		continue;
	}

	for (int32 j = 0; j < HiddenWord.length(); j++)
	{
		if (Guess[i] == HiddenWord[j]) 
		{
			BullCowCount.Cows++;
		}
	}
}
return BullCowCount;}

Are there any performance issues if I wrote my SubmitGuess function like this? The video was showing the different way, but this works for me too.

Hi @Dexit if your code works then your fine. When it comes to using loops with if else statements your going to find that there are many ways to go about it. I actually did mine similar to yours during the challenge and I congratulated myself for my ninja skills since I got the Bulls and Cows to increment correctly. You should congratulate yourself for coming up with the code yourself as this part is pretty complex.

Privacy & Terms