Answered step by step
Verified Expert Solution
Link Copied!

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 >=0
# returns the number of possible arrangements of dogs
# Examples:
# | Input | Output |
# |---------|----------|
# |0,0|1|
# |---------|----------|
# |1,1|2|
# |---------|----------|
# |0,2|0|
# |---------|----------|
# |2,2|12|
# |---------|----------|
def dogArrangements( nPassive, nAggressive ):
return 0
# Testing code provided in main():
def main():
testArgs =[[0,0,1],[1,1,2],[0,2,0],[2,2,12]]
for arg in testArgs:
passive, aggressive, answer = arg
result = dogArrangements(passive,aggressive)
if result != answer:
print(f"Failed dogArrangements test with args nPassive={passive} nAggressive={aggressive}.
Expected: {answer}, Got: {result}")
else:
print(f"Passed dogArrangements test with args nPassive={passive} nAggressive={aggressive}.")
return 0
if __name__=='__main__':
main()
Your solutions should be implemented in python3, 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 solution6.py. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago