6 kyu
Frog jumping
1,228 of 2,862alex.budiakov
Description:
Help the frog to find a way to freedom
You have an array of integers and have a frog at the first position
[Frog, int, int, int, ..., int]
The integer itself may tell you the length and the direction of the jump
For instance:
2 = jump two indices to the right
-3 = jump three indices to the left
0 = stay at the same position
Your objective is to find how many jumps are needed to jump out of the array.
Return -1
if Frog can't jump out of the array
Example:
array = [1, 2, 1, 5];
jumps = 3 (1 -> 2 -> 5 -> <jump out>)
All tests for this Kata are randomly generated.
Fundamentals
Arrays
Algorithms
Similar Kata:
Stats:
Created | May 6, 2014 |
Published | May 6, 2014 |
Warriors Trained | 6827 |
Total Skips | 613 |
Total Code Submissions | 22594 |
Total Times Completed | 2862 |
JavaScript Completions | 1228 |
Java Completions | 722 |
Python Completions | 860 |
CoffeeScript Completions | 20 |
Ruby Completions | 87 |
Factor Completions | 6 |
C Completions | 44 |
D Completions | 6 |
Total Stars | 129 |
% of votes with a positive feedback rating | 94% of 459 |
Total "Very Satisfied" Votes | 407 |
Total "Somewhat Satisfied" Votes | 47 |
Total "Not Satisfied" Votes | 5 |