Question: In a computer generated guessing game, the player should guess a number between 1 and 2 0 . The player has 5 guesses. The player

In a computer generated guessing game, the player should guess a number between 1 and 20. The player has 5 guesses. The player wins if the difference between two or more guesses with the actual number is smaller than or equal to 3.
Ex: The number to be guessed is 9. The player's guesses are [2,14,10,7,3]. Since 10 is larger than 9 by 1, and 7 is smaller than 9 by 2, the player has won this set of the game.
Write a function called NumberGuess() that takes the number to be guessed and a player's guess array, calculates if the winning criteria is met, and returns logical 1 for if the player wins and logical 0 if the player did not.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!