Question: 1)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

1)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 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.  1)Guessing game 2 in a computer generated guessing game, the player
should guess a number between 1 and 20. the player has 5
2) 1D arrays
complete the function ReturnNumbers() which takes one postitive integer(endValue) as an input argument. The function should generate an array of integers from 1 to endValue, and this array return:
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].

My library > ENGR 2304. Programming for Engineers home > 4.14: LAB: Guessing game 2 zyBooks catalog Help/FAQ 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 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 O if the player did not Ex: Given: gameNum=13; and userGuess - [2, 5, 12, 17, 19); Output: logical win- S 4.14: LAB: Guessing game 2 E zyBooks catalog Help/FAQ Function Save C Reset ED MATLAB Documentation 1 function win = NumberGuess (gameNum, userGuess) 2 % Write a function that takes the elements of the row array of user's guesses 3 % and calculates if the difference of 2 or more of the guesses is less than 3. 4 5 end win- 6 Code to call your function > C Reset 1 gameNum - randi ([1, 2], 1) 2 userGuess - randi ([1, 2], (1,5)) 3 win - NumberGuess (GameNum, UserGuess) 1D arrays Complete the function ReturnNumbers() which takes one positive integer (end Value) as an input argument. The function should generate an array of integers from 1 to endValue, and from this array return: oddNumbers: an array of odd numbers between 1 and end Value from smallest number to largest number evenNumbers: an array of even numbers between 1 and end Value from smallest number to largest number reverseNumbers: an array of numbers decreasing from end value to 1 Note: While arrays are double, the entries will be integer numbers. Restriction: Do not use loops, sort, or if else statements. Hint: Use array indexing to select the required numbers to create odd, even and reverse output arrays. Ex Given endvalue = 11 The function ReturnNumbers returns: 5 7 9 11 oddNumbers 1 2 evenumbers - 2 4 roverseNumbers- 11 10 6 8 10 9 8 7 6 5 21 The oddNumbers array contains odd numbers in range 1 to 11. The evenNumbers array contains even numbers in range 1 to 11. The reverseNumbers array contains numbers from 11 to 1 in decreasing order. Function > Save e Reset 20 MATLAB DO 1 function [oddNumbers, evenNumbers, reverseNumbers] = Return Numbers (endValue) 2 % Write a function that return the odd numbers, even numbers and reverse order 3 % numbers between 1 and endValue 4 5 % Contains odd numbers between 1 and end value from smallest number to largest number 6 oddNumbers = returnNumbers (1:endvalue) 7 8 % Contains even numbers between 1 and endvalue from smallest number to largest number 9 evenNumbers - returnNumbers(1:endValue) 10 11 % Contains numbers decreasing from endvalue to 1 12 reverseNumbers - returnNumbers (endValue: 1) 13 end Code to call your function C Reset 1 % endvalue is between 2 and 50. 2 endValue - randi ((2 50],1) 3 [oddNumbers, evenNumbers, reverseNumbers] = Return Numbers (endValue) Run Function 2 Previous Assessment: 3 of 6 Tests Passed (49%) Submit 0% (179) Given a random endValue input, is oddNumbers calculated correctly? 0% (17%) Given a random endValue input, is even Numbers 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!