1 answer

For this problem you need to use Mutual Recursion. This means one function will call another...

Question:

For this problem you need to use Mutual Recursion. This means one function will call another function which will call the first function once again.

This game is two-player game. There are m matches in a box. The players will take turns to remove matches. The player who takes the last match wins. Your friends decided to stick to a certain strategy:

1) Steve loves magic numbers. If the number of matches is divisible by 4, Steve will remove 3 matches, otherwise he will remove only 1 match. If there are 2 or less matches, Steve will take them both and win.

2) Kate loves even numbers. If the number of matches is even, Kate will remove 2 matches, otherwise she will only take 1 (so that the number of matches is even again!). If there are 2 or less matches, Kate will take them both and win.

Assume that there are m matches and the player function called goes first, who wins the game?

Output: You are expected to return one of the following strings, verbatim:

  • "Steve wins the game"
  • "Kate wins the game"
def steve(n):
    """
    >>> steve(1)
    "Steve wins the game"
    >>> steve(5)
    "Steve wins the game"
    """
    # YOUR CODE GOES HERE #
def kate(n):
    """
    >>> kate(1)
    "Kate wins the game"
    >>> kate(2)
    "Kate wins the game"
    """
    # YOUR CODE GOES HERE #

Answers

thanks for the question, here is the simple code in python.

====================================================================================

def steve(n):
    if n<=2:
        print('Steve wins the game')
        return
    if
n%4==0:
        kate(n-3)
    else:
        kate(n-1)

def kate(n):
    if n<=2:
        print('Kate wins the game')
        return
    if
n%2==0:
        steve(n-2)
    else:
        steve(n-1)

steve(1)
steve(5)
kate(1)
kate(2)

====================================================================================

def steve (n): if n<=2: print (steve wins the game) return kate (n-3) else: kate (n-1) def kate (n) if n<-2: print (Kate w

thanks !

.

Similar Solved Questions

1 answer
The following information is available for Whispering Winds Corp. for 2022. Cash used to purchase treasury...
The following information is available for Whispering Winds Corp. for 2022. Cash used to purchase treasury stock$ 122,655 Cash dividends paid55,590 Cash paid for interest57,120 Net income1,183,965 Sales revenue2,045,100 Cash paid for taxes252,450 Cash received from customers1,443,555 Cash received f...
1 answer
Thanks Not yet value frequency 0 1 Paton 1 2 2 6 4 The box plot...
thanks Not yet value frequency 0 1 Paton 1 2 2 6 4 The box plot for the data is Select one a 2 3 (a) ob 0 3 6 0 1 6 0 1 3...
1 answer
The volunteer fire department serving the communities in Figure 1 has only two fire trucks 33...
The volunteer fire department serving the communities in Figure 1 has only two fire trucks 33 B F 19 18 22 29 A D E 31 21 24 30 28 39 Figure 1. a) Select all possible pairs of communities in which the two fire trucks could be located to ensure that all communities can be reached in 34 minutes or les...
1 answer
Dynamics Part A For a short time the bucket of the backhoe traces the path of...
dynamics Part A For a short time the bucket of the backhoe traces the path of the cardioid r. 25(1-cos) ft. The boom is rotating with an angular velocity of ) - 2.5'rad/s and an angular acceleration of ö = 0.18 rad/s at the instant shown. (Figure 1) Determine the magnitude of the veloci...
1 answer
Content CengageNOW.2 Online teachinx CengageNoW2 Assignment helsignment/takeAssignment Main.do?invoker-&takeAssignmentSessionLocator=&inprogress-false Calculator Consencome Statements Kellogg Company (K) produces, markets,...
Content CengageNOW.2 Online teachinx CengageNoW2 Assignment helsignment/takeAssignment Main.do?invoker-&takeAssignmentSessionLocator=&inprogress-false Calculator Consencome Statements Kellogg Company (K) produces, markets, and distributes cereal and food products including Cheez-It, Coco Pop...
1 answer
Explain what is meant by biological aging and include two examples of biological aging
Explain what is meant by biological aging and include two examples of biological aging...
1 answer
What is difference between graphite,bucky ball and diamond?5 differences
What is difference between graphite,bucky ball and diamond?5 differences...
1 answer
1. what are the disadvantages of EHR and HIE? 2. The different between EHR and HIE?...
1. what are the disadvantages of EHR and HIE? 2. The different between EHR and HIE? 3. How EHR and HIE work?...
1 answer
Write a progress report that describes your progress toward your educational goals. Address your progress report...
Write a progress report that describes your progress toward your educational goals. Address your progress report to your parents in a memo format....
1 answer
What is the water solubility of Baco; (Ksp - 2.6 x 10-9 in a solution containing...
What is the water solubility of Baco; (Ksp - 2.6 x 10-9 in a solution containing 040 M CO, (aq)? Answer: Check...
1 answer
Which of the following are capable of forming a buffer solution? What is [H_3O^+] for a...
Which of the following are capable of forming a buffer solution? What is [H_3O^+] for a buffer solution that is 0.200 M in acid and 0.500 M in the corresponding salt if the weak acid Ka = 5.80 Times 10^-7? In the following reaction, identify the oxidizing agent and reducing agent; write the oxidatio...
1 answer
1. (20pts) Figure 1 shows a thick lens. (a) Introduce the system matrix M from surface...
1. (20pts) Figure 1 shows a thick lens. (a) Introduce the system matrix M from surface Ri to surface R2. (b) If the thickness is negligible t- 0 and the lens is surounded by the same material n', find the focal length for this thin lens. (c) Figure 2 show an by a distance L. Find the system matr...
1 answer
How is online networking different from or similar to in-person networking? Please describe your experience with...
How is online networking different from or similar to in-person networking? Please describe your experience with both. 150 words?...
1 answer
Reserve Problems Chapter 12 Section 1 Problem 1 During a research, the amount of Internet users...
Reserve Problems Chapter 12 Section 1 Problem 1 During a research, the amount of Internet users was measured. Each time three random groups of 10,000 people of the average age of 20, 40, and 60 were considered. The data are as follows (x1 - the number of years since the beginning of the research, x2...
1 answer
Timo is an amateur athlete hoping to make it into world-class competitions. At the moment he...
Timo is an amateur athlete hoping to make it into world-class competitions. At the moment he is able to start sprinting with an initial acceleration of 6.25 m/s2 Assuming his mass is 67 kg; calculate the net external force on Timo as he sets off the blocks. Select one: O A. 657.27 N O B. 61.31 N-m O...
1 answer
How are the terms iterative, emergent,epistemology, ontology, and reflexivity used in qualitative research?
How are the terms iterative, emergent,epistemology, ontology, and reflexivity used in qualitative research?...
1 answer
What region does tibia and fibula belong? (1)sural (2)tarsol (3)cortex (4)epicubital.
what region does tibia and fibula belong? (1)sural (2)tarsol (3)cortex (4)epicubital....