I am working on an exercise algorithm problem that reads as follows:

There are eight houses that are represented as cells. Every day, the houses compete with neighboring ones. 1 stands for an "active" house and 0 for an "inactive" house. If the neighbors on either side of a particular home are either both active or both inactive, that home will be inactive the next day. Otherwise it will be active. For example, if we had a group of neighbors (0, 1, 0), the house at (1) would become 0 because both the house on the left and the one on the right are inactive. The cells at both ends have only one adjacent cell, so assume that the unoccupied space on the other side is an inactive cell.

Even after updating the cell, you must remember the previous status when updating the others so that the status information for each cell is updated at the same time.

The function takes the series of states and a number of days and should output the state of the houses after the specified number of days.

```
Examples:
input: states = (1, 0, 0, 0, 0, 1, 0, 0), days = 1
output should be (0, 1, 0, 0, 1, 0, 1, 0)
input: states = (1, 1, 1, 0, 1, 1, 1, 1), days = 2
output should be (0, 0, 0, 0, 0, 1, 1, 0)
```

My solution:

```
def cell_compete(states, days):
for _ in range(days):
prev_cell, next_cell, index = 0, 0, 0
while index < len(states):
if index < len(states) - 1:
next_cell = states(index + 1)
elif index == len(states) - 1:
next_cell = 0
if next_cell == prev_cell:
prev_cell = states(index)
states(index) = 0
else:
prev_cell = states(index)
states(index) = 1
index += 1
return states
```

I used to think of taking advantage of the fact that they are just zeros and ones, and using bitwise operators, but that did not quite work.

Can I improve the efficiency of this algorithm? Any ideas for the "optimal" solution?

Appreciate all feedback, thanks!