7 kyu
Hop Across
257 of 561marbiru
Description:
You are trying to cross a river by jumping along stones. Every time you land on a stone, you hop forwards by the value of that stone. If you skip over a stone then its value doesn't affect you in any way. Eg:
x--x-----x-->
[1][2][5][1]
Of course, crossing from the other side might give you a different answer:
<--------x--x
[1][2][5][1]
Given an array of positive integers, return the total number of steps it would take to go all the way across the river (and past the end of the array) and then all the way back. All arrays will contain at least one element, and may contain up to 100 elements.
Examples
x--x-----x-->
[1][2][1][2]
<----x-----x
therefore hop_across([1,2,1,2]) = 3 + 2 = 5
x-----x--------x------>
[2][2][3][1][1][2][1]
<--------x--x-----x--x
therefore hop_across([2,2,3,1,1,2,1]) = 3 + 4 = 7
Fundamentals
Stats:
Created | Jan 18, 2018 |
Published | Jan 18, 2018 |
Warriors Trained | 1216 |
Total Skips | 46 |
Total Code Submissions | 1455 |
Total Times Completed | 561 |
Python Completions | 257 |
Groovy Completions | 24 |
JavaScript Completions | 161 |
Ruby Completions | 53 |
C# Completions | 111 |
Total Stars | 20 |
% of votes with a positive feedback rating | 91% of 169 |
Total "Very Satisfied" Votes | 146 |
Total "Somewhat Satisfied" Votes | 17 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 7 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |