You are viewing a single comment's thread. Return to all comments →
With Python 3:
Solution 1:
def jumpingOnClouds(c): val = 0 steps = 0 while val < len(c) - 1: if val + 3 <= len(c) and (c[val + 1] == 1 or c[val + 2] == 0 or c[val + 3] == 1): val += 2 else: val += 1 steps += 1 return steps
Solution 2:
def jumpingOnClouds(c): val = 0 steps = 0 while val < len(c) - 1: val = val + 2 if (val + 3 <= len(c) and (c[val + 1] == 1 or c[val + 2] == 0 or c[val + 3] == 1)) else val + 1 steps += 1 return steps
Seems like cookies are disabled on this browser, please enable them to open this website
Jumping on the Clouds
You are viewing a single comment's thread. Return to all comments →
With Python 3:
Solution 1:
Solution 2: