You are viewing a single comment's thread. Return to all comments →
Here is my Python solution! We use a while loop to continually jump k steps forward and subtract the correct amount from the energy.
def jumpingOnClouds(c, k): n = len(c) e = 100 index = 0 while True: index = (index + k) % n e -= 1 if c[index] == 1: e -= 2 if index == 0: return e
Seems like cookies are disabled on this browser, please enable them to open this website
Jumping on the Clouds: Revisited
You are viewing a single comment's thread. Return to all comments →
Here is my Python solution! We use a while loop to continually jump k steps forward and subtract the correct amount from the energy.