You are viewing a single comment's thread. Return to all comments →
Perl solution:
sub jumpingOnClouds { my ($c, $k) = @_; my $energy = 100; my $ind = 0; for (my $i = 0; $i < scalar(@$c); $i++) { $ind = ($k + $ind) % scalar(@$c); $energy--; $energy -= 2 if ($c->[$ind] == 1); last if ($ind == 0); } return $energy; }
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 →
Perl solution: