My IsIsogram() implementation

bool FBullCowGame::IsIsogram(FString Guess) const
{

// treat empty and single letter guesses as isograms (return true immediately)
if (Guess.length() <= 1) { return true; }
	
TMap<char, bool> LetterSeen; // setup the map
for (auto Letter : Guess)	// for all letters of the Guess
{
	Letter = tolower(Letter);	// handle mixed case by setting all to lower case
	if (!LetterSeen[Letter]) 
	{
		LetterSeen[Letter] = true;
	}
	else
	{
		return false;
		break;
	}
}
//return true; 
    // for example, in cases where \0 is entered. Removed as 0 length check takes care of this already.

}

Seemed to work well in testing, handled blanks, string terminator (\0), mixed case, and single characters OK.

Privacy & Terms