**Python Puzzles**

You are conducting a controlled experiment where you have a single cell. After a certain and reoccurring amount of time, the cell has a 2/5 chance of dying, 2/5 chance of being idle, and a 1/5 chance of replicating. After a replication, each cell has the same amount of probability.

Given 1 million trials, what is the maximum number of cells produced?

I routinely get around 75 cells produced, given 1 million trials.

The probability of a trial creating 10 or more cells is only 2%. Given the chart below, you can see how the probability dramatically decreases once the trial begins.

import random import matplotlib.pyplot as plt import pandas as pd result = [] for _ in range(1_000_000): cell = [] cell.append(True) while True in cell: for x in range(len(cell)): # randomly select a number between 1 and 5 random_num = random.randint(1,5) # if the cell is alive and the number is 4 or 5, it dies if cell[x] == True and random_num in (4,5): cell[x] = False # if the cell is alive and the number is 3, it reproduces and a new cell is born elif cell[x] == True and random_num == 3: cell.append(True) # add the final count of cells to the result list result.append(len(cell)) # print the maximum number of cells in any iteration print(max(result)) # create a pandas series and plot the distribution of cell counts df = pd.Series(result) df = df.value_counts() plt.plot(df.index, df.values) plt.title('Distribution of Cell Count') plt.xlabel('Cell Count') plt.ylabel('Frequency') plt.show()