While UserTries < MaxNumberOfTries
Receive UserGuess into UserGuessArray
Reset RandomNumberArrayBoolean to {False, False, False, False}
for each Enumerable.Range(0,4)
item i
if UserGuessArray(i) = RandomNumberArray(i)
then assign RandomNumberArrayBoolean(i) = True
N+1
else do nothing
for each Enumerable.Range(0,4)
item j
if UserGuessArray(i) = RandomNumberArray(j) AND RandomNumberArrayBoolean(j) = False And i <> j
then assign RandomNumberArrayBoolean(j) = True
P+1
break;
else do nothing
I have attached my code if I did not explain very well. I have annotated the sequences inside too
Any advice would be very appreciated
Any advice on best practices would be readily appreciated too!
While UserTries < MaxNumberOfTries
Receive UserGuess into UserGuessArray
Reset RandomNumberArrayBoolean to {False, False, False, False}
For Each i in Enumerable.Range(0, 4)
If UserGuessArray(i) = RandomNumberArray(i)
Then
Assign RandomNumberArrayBoolean(i) = True
Assign P = P + 1
End If
For Each i in Enumerable.Range(0, 4)
For Each j in Enumerable.Range(0, 4)
If UserGuessArray(i) = RandomNumberArray(j) And RandomNumberArrayBoolean(j) = False And i <> j
Then
Assign RandomNumberArrayBoolean(j) = True
Assign N = N + 1
Break
End If
End For
End For
Log Message "Result: " + P + "P " + N + "N"
If P = 4
Then
Log Message "Congratulations! You've guessed the correct number."
Break
End If
Assign UserTries = UserTries + 1