about | help | code help+videos | done | prefs |
Write a method that returns the sum of the numbers in an array, but only include numbers in the sum if they are even numbers in the location of an even index, or odd number in the location of an odd index. For example in {6,5,3,7,4} the 6 would count because it is an even number in index 0 (an even index). The 5 would count because it is an odd number in index 1 (an odd index). The 7 and 4 would also count, but the 3 would not because it is an odd number in an even index. So the sum would be 22. Note that all of the elements of the array will be positive. The array can be any length including an empty array. nov20_2015_HL_partialSum([40, 6, 12, 8, 5, 1]) → 53 nov20_2015_HL_partialSum([5]) → 0 nov20_2015_HL_partialSum([8]) → 8 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy