Giving the code below, for details about the game, read at Wikipedia or play at archimedes-lab.
In the below code, a 4 digit number with unique digits is generated by swapping an array having 10 elements (0 to 9) for N_SWAP number of times. The player is given 8 chances to identify the 4 digit number. For every input, the game will show number of bulls and cows.Digits at the right place are counted as bulls and the digits at the wrong place are counted as cows.
Hint: If bulls + cows = 4, it means the number you entered have the right digits but positionally misplaced.
Example: Let the secret number be 1234. Guessed number be 1203. Now bulls = 2, cows = 1.
No comments:
Post a Comment
Comment will be published after moderation only. Do not advertise here.