Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active October 13, 2015 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/5bebb17ac2251fb58728 to your computer and use it in GitHub Desktop.
Save whatalnk/5bebb17ac2251fb58728 to your computer and use it in GitHub Desktop.
TopCoder SRM 645 Div2
# SRM #645 Div2 Easy
class BacteriesColony():
def performTheExperiment(self, c):
while True:
diff = [0] * len(c)
for i in range(1, len(c)-1):
if c[i] > c[i-1] and c[i] > c[i+1]:
diff[i] = -1
elif c[i] < c[i-1] and c[i] < c[i+1]:
diff[i] = 1
if all([i == 0 for i in diff]):
break
c = [i + j for i, j in zip(c, diff)]
return c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment