Skip to content

Instantly share code, notes, and snippets.

@jouytrew
Created September 1, 2017 06:51
Show Gist options
  • Save jouytrew/9a717f86b0d0d09a0be18e57c6173b18 to your computer and use it in GitHub Desktop.
Save jouytrew/9a717f86b0d0d09a0be18e57c6173b18 to your computer and use it in GitHub Desktop.
// Receives a VALID guess, increments turn, and returns count
FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
{
// increments turn #
MyCurrentTry++;
// setup a return variable
FBullCowCount BullCowCount;
// loop through all letters
int32 HiddenWordLength = MyHiddenWord.length();
for (int32 i = 0; i < HiddenWordLength; i++)
{
// compare against word
for (int32 j = 0; j < HiddenWordLength; j++)
{
// If they match
if (Guess[i] == MyHiddenWord[j])
{
(i == j) ? BullCowCount.Bulls++ : BullCowCount.Cows++;
break;
}
}
}
return BullCowCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment