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

 Guessing game 2 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 fwo or more

Guessing game 2 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 fwo 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 anray, caiculates if the wincing criteria is met, and returns logical 1 for if the player wins and logical 0 if the player did not. Ex: Given: gameNum = 13; and userGuess =[2,5,12,17,19]; Output: win = logica 1 1 function win = NumberGuess (gamellum , userGuess) x write a function that takes the elesents of the row array of user's guesses: z and calculates if the difference of 2 or more of the guesses is less, than 3 . win = end Code to call your function ? 1 gameNum = randi ([1,20],1) 2 userGuess = randi ([1,2],[1,5]) 1 win = NumberGuess (gameNum , usenGuess) Check if gameNum =11, userGuess =[10,2,13,14,20] returns logical 1 Check that given a random gameNum and userGuess, win is calculated correctly

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 Databases Questions!