Question: Python assignment. 2. Use recursion to create a function recursive_urns() which does the same thing. It can return either a list of tuples, or a

Python assignment.

2. Use recursion to create a function recursive_urns() which does the same thing. It can return either a list of tuples, or a list of lists for the answer. Pick whichever is easier for you.

>>> recursive_urns(13,4,2,4) [[4, 4, 3, 2], [4, 3, 4, 2], [3, 4, 4, 2], [4, 4, 2, 3], [4, 3, 3, 3], [3, 4, 3, 3], [4, 2, 4, 3], [3, 3, 4, 3], [2, 4, 4, 3], [4, 3, 2, 4], [3, 4, 2, 4], [4, 2, 3, 4], [3, 3, 3, 4], [2, 4, 3, 4], [3, 2, 4, 4], [2, 3, 4, 4]]

>>> recursive_urns(5,7,0,1) [[1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0], [1, 1, 0, 1, 1, 1, 0], [1, 0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 1, 1], [0, 1, 1, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1]]

>>> recursive_urns(30,4,2,5) []

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!