Snippets Collections
def cellCompete(states, days):
	for day in range(days):
    	newStates = states[:]

		for i in range(len(states)):
        	if i == 0:
            	if states[i+1] == 0:
                	states[i] = 0
				else:
                	states[i] = 1
            elif i == len(states) - 1:
            	if states[i-1] == 0:
                	states[i] = 0
				else:
                	states[i] = 1
            else:
            	if states[i-1] == states[i+1]:
                	newStates[i] = 0
				else:
                	newStates[i] = 1
		states = newStates[:]
	return states
star

Mon Feb 21 2022 19:08:36 GMT+0000 (Coordinated Universal Time)

#python #cells #houses #inactive #active #bruteforce

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension