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....
-
Using the information from BE14- 11, determine the issue price of the bonds, assuming that the market rate of interest is 6%, and prepare the journal entry to record the bond issue under IFRS using...
-
Reconsider Problem 6.5. Suppose now that, for administrative convenience, management has decided that all 130 units per month needed at the distribution center in Los Angeles must come from the...
-
As a normal part of tests of controls for cash disbursements, an auditor examines signatures and endorsements on canceled checks, if they're available, looking specifically for unusual items. Give...
-
The stockholders?? equity T accounts of Life??s Greeting Cards Inc. for the current fiscal year ended December 31, 2012, are as follows. Prepare a statement of stockholders?? equity for the fiscal...
-
What are your thoughts/reflections on the reading? Do you agree/disagree? Edwin Not Every Student Should Go to College. And That's OK By Michael B. Hom & Bob Moesta Forty years ago 32 percent of...
-
J.A. Coghill owned a used Rolls Royce Corniche automobile, which he sold to a man claiming to be Daniel Bellman. Bellman gave Coghill a cashiers check for $ 94,500. When Coghill tried to cash the...
-
You are about to start working at a car dealership that is currently reporting losses due to the car shortage associated with the Covid-19 pandemic but will be profitable next year. Assume you are...
-
Consider a flow network G = (V,E) with positive edge capacities {c(e)}. Let f: E Ro be a maximum flow in G, and G be the residual graph. Denote by S the set of nodes reachable from s in G and by T...
-
Assume you are the new global manager for Continental Cruise Ltd, which sails to popular European and Asian cities. You receive the quarterly profit and loss statement reports and notice that it is...
-
Some people have less common chromosome combinations, such as XYY and XXX, as a result of nondisjunction. What does nondisjunction mean?
-
1. You body contains 2 x 1025 molecules, most of which can be classified as being a part of one of the four fundamental biological molecule classes. (a) Please state all four of these fundamental...
-
What are the Impacts of IPT on Micro, Mezzo and Macro Treatment. Include References ?
-
The table shown here gives a cost-of-living index for 14 different cities. Currently, you are living and working in Phoenix and earning $115000 per year, but you are considering a move to Manhattan....
-
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...
-
There is a flat plate with a base area of 5 kg, sliding along the slant at an angle of 20 with the horizontal plane 60 cm times 40 cm 60 c m times 40 cm. The thickness of the oil layer between the...
-
Assume two periods to expiration, \(u=1.05, d=1 / 1.05, r_{f}=1.02, S_{0}=\$ 100\), no dividends, and \(X=\$ 100\) on a European put expiring at the end of the second period. a. Find: \(P_{u w}, P_{u...
-
Using the put-call parity model, determine the equilibrium price of the put in Question 1, given the equilibrium call value as determined by the binomial model. Comment on the consistency of the...
Study smarter with the SolutionInn App