Hey guys i got a question about the 67th lecture in the Bulls and Cows Section of the C++ learning course for Unreal Engine.
i’ have followed the lecture and i have almost everything exactly the same, the only difference in the IsIsogram() function of mine is that i declared the initialization of the for loop differently , ill provide the code below as well as screenshots of the desired output (the way the instructor did it) and the output i get.
some elaboration about the code, the commented bit, which is also a FOR loop ,is a code i had to copy from someone to compare it to mine i couldn’t and still cant find out whats wrong. ive only declared my initialization variables differently.
here’s the code:
bool UBullCowCartridge::IsIsogram(FString Word)const //d|i|r|e|c|t|o|r
{
//check first letter against the rest
int32 Index = 0;
int32 Comparison = Index +1;
for(Index; Index < Word.Len(); Index++)
{
for(Comparison;Comparison < Word.Len(); Comparison++)
{
if (Word[Index] == Word[Comparison])
{
return false;
}
}
}
// for (int32 Index = 0; Index < Word.Len(); Index++)
// {
// for (int32 Comparison = Index +1; Comparison < Word.Len(); Comparison++)
// {
// if (Word[Index] == Word[Comparison])
// {
// return false;
// }
// }
// }
return true;
}
i had assumed they would be the same , here are the screenshots:
My Output:
and this is the output i want ( the commented out code gives this output):
any help or explanation on whats happening is greatly appreciated , Thanks in advance