Order of checks and reasoning

I decided to do a few things here. I put my first check to see if the right number of characters were typed. If not I didn’t dock a life and simply told them how many letters they should have typed and try again. That way if they accidently hit ENTER without typing anything, they are not penalized and if they type wrong # of characters, they can try again without losing a life. If you don’t make this the first check then they could get docked a life if you check if the guess != hiddenword first as that would cause a life to be lost regardless of the reason.

My first check was simply “is the word right” because if it is, there is no need to check length or isogram because the words match. This would speed up the code execution.

This was followed by whether the guess was shorter OR longer than the hidden word with but I didn’t deduct a life if the word wasn’t the right length.

Then I start to check when the right number of letters have been entered starting with whether it is an isogram or not. As this will involve comparing letters against each other, this is the most complex of the checks so am doing it last.

1 Like

I made the first check a test of whether they already had the answer correct. Because if that is true no need to bother making any further checks. So it is the most logical first check.

My second check was word length.

I then decremented a life (–Lives) so that the checks above led to no penalty, but the following checks do.

The third check was to see if it is an isogram.

Fourth check I made last because by process of elimination, it must be the case that the word is the right length but the incorrect word. Thus I required no if statement.

Privacy & Terms