""" Use this file to develop and test your Assignment 3 functions S0, 2020.""" def main(): print_header(4, "get_memory_score()") test_get_memory_score() #-------------------------------------------------- # 4444444444444444444444444444444444444444444444444 # Returns the score from a memory game. # The strategy is to remove the number that has # been in the memory the longest time. #-------------------------------------------------- """ A memory game is played (and scored) as follows: Random numbers between 0 and 10 (zero 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, 3], the game proceeds as follows: Called number 3: Score: 0, Numbers in memory: [3] Called number 4: Score: 0, Numbers in memory: [3, 4] Called number 3: Score: 1, Numbers in memory: [3, 4] Called number 0: Score: 1, Numbers in memory: [3, 4, 0] Called number 7: Score: 1, Numbers in memory: [3, 4, 0, 7] Called number 4: Score: 2, Numbers in memory: [3, 4, 0, 7] Called number 5: Score: 2, Numbers in memory: [3, 4, 0, 7, 5] Called number 2: Score: 2, Numbers in memory: [4, 0, 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, 0, 0])) 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, 2])) 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, 0, 3] print("5. Score:", get_memory_score(random_nums5)) prints: 1. Score: 4 2. Score: 6 3. Score: 8 4. Score: 0 5. Score: 10 """ def get_memory_score(random_numbers): return 0 def test_get_memory_score(): 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, 0, 3] random_nums6 = [0, 8, 4, 4, 4, 1, 7, 3, 3, 5, 1, 6, 9, 1, 1, 2, 1, 5, 3, 7, 3, 0, 5, 7, 8] random_nums7 = [1, 1, 1, 0, 1, 0, 2, 2, 1, 2, 0, 1, 2, 0, 3, 4, 1, 2, 4, 0, 1, 2, 4, 0, 4, 6, 1, 2, 4, 6, 0, 1, 2, 4, 6, 0, 5, 1, 1, 2, 4, 6, 1, 1, 2, 4, 6, 1, 6, 8, 1, 2, 4, 6, 8, 1, 1, 2, 4, 6, 8, 1, 7, 10, 1, 4, 6, 8, 10, 1, 2, 4, 6, 8, 10, 1, 8, 2, 1, 2, 6, 8, 10, 1, 2, 4, 6, 8, 10, 2, 9, 4, 1, 2, 4, 8, 10, 1, 2, 4, 6, 8, 10, 3, 10, 1, 1, 2, 4, 8, 10, 2, 1, 4, 6, 8, 10, 3] print("1. ", get_memory_score([3, 4, 1, 6, 3, 3, 9, 0, 0, 0])) print("2. ", get_memory_score([1, 2, 2, 2, 2, 3, 1, 1, 8, 2])) print("3. ", get_memory_score([2, 2, 2, 2, 2, 2, 2, 2, 2])) print("4. ", get_memory_score([1, 2, 3, 4, 5, 6, 7, 8, 9])) print("5. ", get_memory_score(random_nums5)) print("6. ", get_memory_score(random_nums6)) print("7. ", get_memory_score(random_nums7)) print() #-------------------------------------------------- # Print header lines #-------------------------------------------------- def print_header(number, text): text = str(number) + ". " + text print("-" * 30) print(str(number) * 30) print(text) print("-" * 30) main()