Question: Specification: hiddenWord and userGuess are both length- 5 strings containing lower case letters. The function returns a list L of 5 numbers, each of which

 Specification: hiddenWord and userGuess are both length- 5 strings containing lowercase letters. The function returns a list L of 5 numbers, each

Specification: hiddenWord and userGuess are both length- 5 strings containing lower case letters. The function returns a list L of 5 numbers, each of which can be 0,1 , or 2 . For i=0,1,2,3,4, element L[i] will represent the "status" of the letter userGuess[i]. We will use the following rule to assign a status to each letter in userGuess: 0= letter does not appear in hiddenWord 1 = letter appears in hiddenWord, but not in the correct position 2= letter appears in hiddenWord in the correct position Examples: evaluateWord("snake", "boats") should return [0, 0, 2, 0, 1] evaluateWord("stole", "broom") should return [0,0,2,1,0] Note: If a letter in userGuess appears in hiddenWord in both matching and non-matching positions, then its status should be 2. Example: evaluateWord("slots", "boats") should return [0, 1, 0, 2, 2] Here globalLetterStatus is a length-26 array of numbers, which can be 1,0,1, and 2, userGuess is a 5-letter string with lower case letters, and letterStatus is a length-5 array with numbers 0,1 , and 2 . The idea is that globalLetterStatus[0] contains the status of the letter "a", globalLetterStatus[1] contains the status of the letter "b", globalLetterStatus[2] contains the status of the letter "c", etc. The meaning of the numbers in the globalLetterStatus list is as follows: -1 = corresponding letter has never appeared in any prior user guesses 0 = corresponding letter has appeared in a prior user guess, but does not appear in the hidden word 1 = corresponding letter has appeared in a prior user guess, but its position in the hiddenWord is not known to the user 2 = corresponding letter has appeared in a prior user guess, and its position in the hiddenWord is known to the user The function updates the list globalLetterStatus based on the current userGuess and letterStatus. Examples: Suppose globalLetterStatus =[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1], userGuess = "testy", and letterStatus =[0,1,1,0,0]. Then calling updateGlobalLetterStatus(globalLetterStatus, userGuess, letterStatus) modifies globalLetterStatus to [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1] Suppose globalLetterStatus =[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1], userGuess = "gruel", and letterStatus = [0,0,0,1,0]. Then calling updateGlobalLetterStatus(globalLetterStatus, userGuess, letterStatus) modifies globalLetterStatus to [1,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,1,1,0,1] Suppose globalLetterStatus =[1,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,1,1,0,1], userGuess = "stale", and letterStatus = [2, 0, 2, 0, 2]. Then calling updateGlobalLetterStatus(globalLetterStatus, userGuess, letterStatus) modifies globalLetterStatus to [2,1,1,1,2,1,0,1,1,1,1,0,1,1,1,1,1,0,2,0,0,1,1,1,0,1]

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!