Last active
October 13, 2015 04:00
-
-
Save whatalnk/5bebb17ac2251fb58728 to your computer and use it in GitHub Desktop.
TopCoder SRM 645 Div2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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