We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Jumping on Clouds Function below in python
def jumpingOnClouds(c, k):
n = len(c)
energy = 100 # start with full energy
i = 0 # start at the first cloud
while True:
# Move i to the next cloud considering the circular array
i = (i + k) % n
# Decrease energy by 1 for the jump
energy -= 1
# If it's a thundercloud, lose an additional 2 energy
if c[i] == 1:
energy -= 2
# If we're back at the start, break out of the loop
if i == 0:
break
return energy
This function iterates through the clouds, adjusts the index based on the jump size k, and updates the energy according to the cloud type.
In a way, this challenge reminds me of editing a complex video sequence using VN Video Editor, where you often loop through clips and apply different effects strategically to enhance the final output.
Cookie support is required to access HackerRank
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 →
Jumping on Clouds Function below in python def jumpingOnClouds(c, k): n = len(c) energy = 100 # start with full energy i = 0 # start at the first cloud
return energy
This function iterates through the clouds, adjusts the index based on the jump size k, and updates the energy according to the cloud type.
In a way, this challenge reminds me of editing a complex video sequence using VN Video Editor, where you often loop through clips and apply different effects strategically to enhance the final output.