I am trying to build a guessing game that requires a user to enter a valid 4-digit in an attempt to guess the random number generated by the workflow. For every attempt made by each user, I want to show the “correctness” of the result.
For instance, if the randomly generated number is 1234 and a user enters 1345, I want to prompt a message box to show “2A” and “1B” respectively. “2A” signifies two correct numbers but in the wrong position (in this case numbers 3 and 4) while “1B” signifies 1 correct number in the correct position (in this case number 1).
May I know which activity(es) can be used to incorporate the aforementioned into the workflow? Any help is greatly appreciated!
This is a brilliant idea for a bot-run game!
You should be able to implement this by using mainly two String methods:
String.Contains
String.IndexOf
Run a loop on the digits of the number randomly generated by the workflow.
Check if user input contains that digit by using Contains method.
If yes, check if the IndexOf that digit matches the index of that digit in your number.
This in conjunction with If activity blocks should get you the desired result.
Cheers!
In this case, the randomly generated number is 6902. But when 6909 is entered, “1A 3B” is shown because the second digit ‘9’ is still found within the randomly generated number. However, the output I expected to see is “0A 3B” since the second digit ‘9’ do not belong anywhere in the randomly generated number anymore. Would like to hear your inputs on this, thank you so much!