TArray<FString> UBullCowCartridge::GetValidWords() const
{
TArray<FString> AllWords;
TArray<FString> FilteredWords;
const FString WordListPath = FPaths::ProjectContentDir() / TEXT("Words.txt");
FFileHelper::LoadFileToStringArray(AllWords, *WordListPath);
FilteredWords = AllWords.FilterByPredicate([this](const FString& Str)
{
int32 Length = Str.Len();
return Length >= 4 && Length <= 8 && this->IsIsogram(*Str);
});
PrintLine(TEXT("Possible words count is %i"), FilteredWords.Num());
return FilteredWords;
}
3 Likes
Hi and welcome to the community. Nice solution.
The reason I wouldn’t necessarily do it this way is that it makes the code more complex to follow and thus less maintainable.
It is nonetheless a good solution to the problem.
1 Like