Here is my implementation of the method IsIsogram(), which I’m not sure if it looks very pretty or efficient. It does work as far as I have tried, but I have the feeling it is not as correct as it should be.
bool FBullCowGame::IsIsogram(FString guess) const
{
if (guess.length() <= 1) { return true; }
TMap<char, bool> LetterSeen;
for (auto Letter : guess) //for all letters of guess
{
Letter = tolower(Letter);
if (LetterSeen.find(Letter) == LetterSeen.end())
{
LetterSeen.insert(std::pair<char, bool>(Letter, true));
}
else
{
return false;
}
}
return true;
}
Edit: Okay, just saw the video’s solution, and working with the map is much simpler that I thought (or that it tells you on the references on the internet as I didn’t see one example where it told you you can access maps like that)