I'm trying to make a program that tracks how an (example) cell colony would grow. It's very simple;
- cell starts at age 0
- at age 1 cell is adult able to reproduce, creating 1 cell each year (slow, I know)
- at age m cell dies
- we want the number of cells after n years Example:n = 6 and m = 3 results in 4 cells
I tried to solve this by creating two lists:
babies = [0] (one starting cell)
adults = []
My plan was moving each baby_cell to the adult list after the baby would be age 1, this is also where the problem lies. This is what I wrote:
index = 0
for baby in babies:
if baby == 1:
adults.append(baby)
del babies[index]
index += 1
It only moves one cell, so if babies = [1, 1] it will only remove one of the two and leave the other one there. Over time these accumulate, and you end up with a babies list full of adults...
I have never been this stuck since I started programming. I'm probably overlooking something simple, but still, I need help!