BullCowGame Lecture 68 shortcut

What I found out for the challenge was, you didn’t have to do a nested for loop for it. Just type 9 characters and you are done. Here is the code:

Before doing the challenge:

for (int32 Index = 0, Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
    {
        if (Word[Index] == Word[Comparison])
        {
            return false;
        }
        
    }

After doing shortcut:

for (int32 Index = 0, Comparison = Index + 1; Comparison < Word.Len(); Comparison++, Index++)
    {
        if (Word[Index] == Word[Comparison])
        {
            return false;
        }
        
    }

As you can see, I just added the , Index++ part. Therefore, you don’t have to do a nested for loop.

1 Like

Thank you for sharing this!