Question on the if statement

So In the logic, Guess and hiddenword index values are both compared twice, once in each loop. Is it worth the time to add the logic in the second if statement to prevent that?
e.g. the GuessIndex != HiddenIndex

The continue statement after the Bullcount++ make the check for GuessIndex != HiddenIndex redundant; if Guess[GuessIndex] is equal to HiddenWord[GuessIndex] the for loop inside is skipped entirely

1 Like

Ooh I’ve just realised my mistake, I was thinking that logic would prevent the HidenIndex==GuessIndex comparison in the second for loop when the first if statement is false, forgetting that it won’t just skip the iteration of the for loop. I get the part you said, it helped me figure out my mistake

Thanks for the reply

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms