An urn contains 75 white marbles and 150 black marbles. An inexhaustible pile of black marbles is also available. Repeatedly apply the following two-step operation: first withdraw two marbles at random from the urn, and then
if both are black, put one of them back in the urn and throw the other away
if one is black and the other white, put the white one back and throw the black one away
if both are white, throw both away and put a black marble from the pile into the urn
Because the urn loses a marble at each step, eventually it will contain a single marble. What color is that last marble?
An urn containing $$w$$ white and $$b$$ black marbles is represented as a sequence (list or tuple) that contains $$w$$ occurrences of the string white (str) and $$b$$ occurrences of the string black (str). Although there is no predefined order of the marbles contained in the urn, its representation as a sequence imposes an order on the marbles that makes it possible to indicate a particular marble at a given position. Your task:
Write a function fill that takes an integer $$n \in \mathbb{N}$$ (int). The function must return an urn (list) that contains $$n$$ marbles in total. The function must guarantee that the color of each marble in the urn is randomly chosen between the colors black and white, independent of the position of the marbles in the list (list) that represents the urn.
Write a function pick that takes an urn (list or tuple) containing black and white marbles. The function must return a tuple containing two integers (int) that indicate two different positions into the sequence representing the urn. Make sure the function does not alter the argument passed to the function.
Write a function remove that takes three arguments. The third argument represents an urn (list) containing black and white marbles, and the first and second argument indicate different positions (int) of two marbles contained in the list that represents the urn. The function must remove the two marbles at the given positions in the list representing the urn, and add a new marble to the end of the list whose color is determined by the colors of the marbles withdrawn from the list using the procedure described in the introduction.
Write a function last that takes an urn (list or tuple) containing black and white marbles. The function must return the color (str) of the last marble that remains in the urn after having executed the procedure described in the introduction. Make sure the function does not alter the argument passed to the function.
>>> urn = fill(10)
>>> urn
['white', 'white', 'black', 'black', 'black', 'white', 'white', 'white', 'white', 'black']
>>> marble1, marble2 = pick(urn)
>>> marble1, marble2
(1, 9)
>>> remove(marble1, marble2, urn)
>>> urn
['white', 'black', 'black', 'black', 'white', 'white', 'white', 'white', 'white']
>>> last(urn)
'black'