Question 1. There is a colony of 8 cells arranged in a straight line where each
day ery cell competes with its adjacent cells (neighbor). Each day, for each
cell, if its neighbors are both active and both inactive, the cell becomes
inactive the next day, otherwise it becomes active the next day.
Assumptions: The two cells on the ends have single adjacent cell, so the
other adjacent cell can be assumed to be always inactive.
Even after updating the cell state. Consider its previous state for updating the
state of other cells. Update the cell information of all cells simultaneously.
Write a function cell Compete which takes one 8 element array of integer's cells
representing the current state of 8 cells and one integer days representing the
number of days to simulate.
An integer value of 1 represents an active cell and value of 0 represents an
inactive cell.
Existing Programce-Expertise-Experience
int* cellCompete(int* cells.int days)
{/
/write your code here
}
//function signature ends
Test Cases
TESTCASES 1:
INPUT:
[1.0.0,0,0,1,0,0],1
EXPECTED RETURN VALUE:
[0.1.0.0.1.0.1.0]
30
TESTCASE 2:
[1.1.1.0.1.1.1.1.1.2.
INPUT:
EXPECTED RETURN VALUE:
[0,0,0,0,0,1,1,0]