Implementation of IsIsogram() function

bool FBullCowGame::IsIsogram(FString Guess) const
{
//treat 0 and 1 letter words as isograms
if (Guess.length() < 2) { return true; }

//Decalre a map
TMap<char, bool> LetterSeen;

for (auto Letter : Guess) //Range based loop , for all letters in Guess
{
    Letter = tolower(Letter);

    if (LetterSeen[Letter])
    {//If we return more than one occurence of a letter
        return false;//we do not have an isogram
    }
    else 
    {//otherwise 
        LetterSeen[Letter] = true;//add the letter to the map as seen
    }
}
return true;  //for example Guess is /0

Privacy & Terms