IsIsogram

bool FbullCowGame::IsIsogram(FString Guess) const
{
// treat 0 and 1 letter words as isograms
if (Guess.length() <= 1) { return true; }
TMap<char, bool> LetterSeen; // setup TMap

for (auto Letter : Guess) // Loop through each letter
{

	Letter = tolower(Letter); // handle mixed case
	
	if (LetterSeen[Letter] == true) { return false; } // Check if Letter has already been seen if so return false
	else { LetterSeen[Letter] = true; } // if it has not been seen add it to the map
	
	
}


return true; // return true after finishing the loop and not finding a dubplicate

}

Privacy & Terms