bool FBullCowGame::IsIsogram(FString Guess) const { std::unordered_set<char> SeenLetters = {}; for (char Letter : Guess) { if (SeenLetters.count(Letter) > 0) { return false; } else { SeenLetters.insert(Letter); } } return true; }
Great job, that’s a perfect solution
Nice to see a worked unordered set example.
My implementation also ignores case and I treat an empty input as the player giving up.
For reasons given on this actually being an O(1) procedure, I did not bother to switch to the use of TMap, although it is nice to see its use.
TMap and TSet should be of exciting value in more-elaborate games and having an enumeration class as the domain should be especially fun if it works.
I am resisting the itch to attempt a BullCowGame solver heuristic so far. Not certain I can hold out .
1 Like