Skip to content

Instantly share code, notes, and snippets.

@rachidelaid
Created April 26, 2022 07:33
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 rachidelaid/533b2c3262bcee47789573ee1be944ba to your computer and use it in GitHub Desktop.
Save rachidelaid/533b2c3262bcee47789573ee1be944ba to your computer and use it in GitHub Desktop.
function jumpingOnClouds(c, k) {
let index = 0;
let energy = 100;
let stop = false;
while (!stop) {
if (c[index] === 1) {
energy -= 2;
}
energy -= 1;
index = (index + k) % c.length;
if (index === 0) {
stop = true;
}
}
return energy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment