Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are a volunteer at a dog rescue. Your job is to feed the dogs dinner, however the dogs you feed consist of dogs with
You are a volunteer at a dog rescue. Your job is to feed the dogs dinner, however the dogs you feed consist of dogs with food aggression and passive dogs. When you put all the doggie bowls in a line, you need to make sure that no two aggressive dogs are beside each other, or else they will fight over the food and cause a mess. Implement the routine: dogArrangements which takes in the number of aggressive and passive dogs nAggressive, and nPassive and returns the number of ways you can arrange their dog bowls in a line such that no dogs fight. Assume the dogs are distinguishable.
Use the following template:
# takes in nAggressive, nPassive
# returns the number of possible arrangements of dogs
# Examples:
# Input Output
#
#
#
#
#
#
#
#
#
def dogArrangements nPassive, nAggressive :
return
# Testing code provided in main:
def main:
testArgs
for arg in testArgs:
passive, aggressive, answer arg
result dogArrangementspassiveaggressive
if result answer:
printfFailed dogArrangements test with args nPassivepassive nAggressiveaggressive
Expected: answer Got: result
else:
printfPassed dogArrangements test with args nPassivepassive nAggressiveaggressive
return
if namemain:
main
Your solutions should be implemented in python so please ensure that you use this python version when testing your assignment before submission. You must submit your implementation of this routine inside a file named solutionpy Any change in name of the provided routines, or name of your submitted file will result in failure of the autograded tests. Furthermore, all code submitted should be inside routines. Do not leave any
code outside the routines.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started