A memory game is played (and scored) as follows: Random numbers between 0 and 10 (both...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A memory game is played (and scored) as follows: Random numbers between 0 and 10 (both inclusive) are called out one at a time. In this memory game the player can remember a maximum of 5 previously called out numbers. If the called number is already in the player's memory, a point is added to the player's score. If the called number is not in the player's memory, the player adds the called number to his memory. first removing another number if his memory is full. In our simulation of this game, the number which is removed from the player's memory is the number that has been in the player's memory the longest time. For example, if the random numbers are [3, 4, 3, 0, 7, 4, 5, 2, 1, 31, the game proceeds as follows: Called number 3: Score: e, Numbers in memory: [3] Called number 4: Score: e, Numbers in memory: [3, 4] Called number 3: Score: 1, Numbers in memory: [3, 4] Called number e: Score: 1, Numbers in memory: [3, 4, 0] Score: 1, Numbers in memory: [3, 4, 8, 7] Score: 2, Numbers in memory: [3, 4, 8, 7] Score: 2, Numbers in memory: [3, 4, 8, 7, 5] Called number 7: Called number 4: Called number 5: Called number 2: Score: 2, Numbers in memory: [4, 8, 7, 5, 2] Called number 1: Score: 2, Numbers in memory: [0, 7, 5, 2, 1] Called number 3: Score: 2, Numbers in memory: [7, 5, 2, 1, 3] Complete the get_memory_score() function which is passed a list of random numbers as a parameter and returns the final score using the algorithm described above. For example, the following code: print("1. Score:", get_memory_score([3, 4, 1, 6, 3, 3, 9, 0, e, 8])) print("2. Score:", get_memory_score([1, 2, 2, 2, 2, 3, 1, 1, 8, 2])) print("3. Score:", get_memory_score([2, 2, 2, 2, 2, 2, 2, 2, 21)) print("4. Score:", get_memory_score([1, 2, 3, 4, 5, 6, 7, 8, 9])) random_nums5 = [7, 5, 8, 6, 3, 5, 9, 7, 9, 7, 5, 6, 4, 1, 7, 4, 6, 5, 8, 9, 4, 8, 3, e, 3] print("5. Score:", get_memory_score(random_nums5)) prints: 1. Score: 4 2. Score: 6 3. Score: 8 4. Score: 0 5. Score: 18 A memory game is played (and scored) as follows: Random numbers between 0 and 10 (both inclusive) are called out one at a time. In this memory game the player can remember a maximum of 5 previously called out numbers. If the called number is already in the player's memory, a point is added to the player's score. If the called number is not in the player's memory, the player adds the called number to his memory. first removing another number if his memory is full. In our simulation of this game, the number which is removed from the player's memory is the number that has been in the player's memory the longest time. For example, if the random numbers are [3, 4, 3, 0, 7, 4, 5, 2, 1, 31, the game proceeds as follows: Called number 3: Score: e, Numbers in memory: [3] Called number 4: Score: e, Numbers in memory: [3, 4] Called number 3: Score: 1, Numbers in memory: [3, 4] Called number e: Score: 1, Numbers in memory: [3, 4, 0] Score: 1, Numbers in memory: [3, 4, 8, 7] Score: 2, Numbers in memory: [3, 4, 8, 7] Score: 2, Numbers in memory: [3, 4, 8, 7, 5] Called number 7: Called number 4: Called number 5: Called number 2: Score: 2, Numbers in memory: [4, 8, 7, 5, 2] Called number 1: Score: 2, Numbers in memory: [0, 7, 5, 2, 1] Called number 3: Score: 2, Numbers in memory: [7, 5, 2, 1, 3] Complete the get_memory_score() function which is passed a list of random numbers as a parameter and returns the final score using the algorithm described above. For example, the following code: print("1. Score:", get_memory_score([3, 4, 1, 6, 3, 3, 9, 0, e, 8])) print("2. Score:", get_memory_score([1, 2, 2, 2, 2, 3, 1, 1, 8, 2])) print("3. Score:", get_memory_score([2, 2, 2, 2, 2, 2, 2, 2, 21)) print("4. Score:", get_memory_score([1, 2, 3, 4, 5, 6, 7, 8, 9])) random_nums5 = [7, 5, 8, 6, 3, 5, 9, 7, 9, 7, 5, 6, 4, 1, 7, 4, 6, 5, 8, 9, 4, 8, 3, e, 3] print("5. Score:", get_memory_score(random_nums5)) prints: 1. Score: 4 2. Score: 6 3. Score: 8 4. Score: 0 5. Score: 18
Expert Answer:
Answer rating: 100% (QA)
Solution Functions Code Screenshots Functions Code To Copy Define the function getmemoryscore def ge... View the full answer
Related Book For
Posted Date:
Students also viewed these accounting questions
-
Write a do/while loop that repeatedly prints random numbers between 0 and 1000 until a number above 900 is printed. At least one line of output should always be printed, even if the first random...
-
A game is played as follows: A random number X is chosen uniformly from [0, 1]. Then a sequence Y1, Y2, . . . of random numbers is chosen independently and uniformly from [0, 1]. The game ends the...
-
One player makes 5 out of 10 shots, another makes 9 out of 10. Use the method of support to test whether the above samples differ.
-
Two capillary tubes of the same radius r but of lengths & and 1 are fitted horizontally to the bottom of a tall vessel containing a liquid at constant Pressure head and flowing through these tubes....
-
Congressman Steve Cohen, Democrat of Tennessee, wrote a letter in 2009 to the National Basketball Association and the NBA players union asking them to repeal the rule requiring players to be 19 years...
-
What lessons does Escott v. BarChris Construction Corp. offer about an inexperienced audit staff?
-
A corporation's income tax payable is computed as: a. Income before tax \(\times\) Income tax rate b. Taxable income \(\times\) Income tax rate c. Net income \(\times\) Income tax rate d. Return on...
-
A candidate for mayor in a small town has allocated $40,000 for last-minute advertising in the days preceding the election. Two types of ads will be used: radio and television. Each radio ad costs...
-
You have been hired as an analyst for Mellon Bank and your team is working on an independent assessment of Daffy Duck Food Inc. (DDF Inc.) DDF Inc. is a firm that specializes in the production of...
-
After its first month of operations, Paquette Advisors showed the following account balances in its General Ledger accounts as at January 31, 2014. During February, the following transactions...
-
f the loop exits after executing only two iterations, draw a pipeline diagram for your MIPS code executed on a 2-issue processor shown in Figure 4.69. Assume the processor has perfect branch...
-
Read Exculpatory Clause and the facts of Buzz Buff v. Awesome Abs, Inc., and formulate a response to various criteria about an exculpatory clause. There is more than one basis for determining whether...
-
Bonnie and Asha, two college students, are in a restaurant. They get into a heated argument about their criminal law examination. Bonnie sweeps her arm across the table angrily, purposely knocking...
-
Company B has entered into a forward rate agreement (FRA) where it will receive 4% with quarterly compounding (for 3-month period) and pay the 3-month LIBOR rate observed in 2 years. The interest...
-
Firm A is a publicly traded company. The equity beta for the company is 1.2, the risk-free rate is 2%, and the market risk premium is 7%. What is the cost of equity for this company?
-
The figure 1 below shows a Third orthographic projection of a drawing, use this drawing to construct an isometric drawing of the figure by making point A the lowest point in your drawing. A 30 15 75...
-
Canadian Tire is providing a one-day training session for its retail employees on the topic of customer service at one of its Toronto stores. Review the various methods of needs analysis presented in...
-
The Ranch 888 Noodle Company sells two types of dried noodles:ramen, at $6.50 per box, and chow fun, at $7.70 per box. So farthis year, the company has sold a total of 110,096 boxes ofnoodles,...
-
Example 1 in this section used performance IQ scores from Data Set 5 in Appendix B for two-way analysis of variance with the factors of sex (male, female) and measured blood lead level (low, medium,...
-
A TNS poll of 1000 randomly selected adults showed that 460 of them say that public speaking is an activity that they dread most. Shown next is the StatCrunch display resulting from a test of the...
-
The Genetics and IVF Institute conducted a clinical trial of the XSORT method designed to increase the probability of conceiving a girl. As of this writing, 945 babies were born to parents using the...
-
Third quartile = _______
-
Interquartile range (IQR) = _____ _____ = _____
-
Find the mean for the following frequency tables. Frequency a. Grade 49.5-59.5 2 59.5-69.5 3 69.5-79.5 8 79.5-89.5 12 89.5-99.5 5 Table 2.51 b. Daily Low Temperature Frequency 49.5-59.5 53 59.5-69.5...
Study smarter with the SolutionInn App