6 kyu

Selective Array Reversing

1,163 of 2,287kodejuice

Description:

Given an array, return the reversed version of the array (a different kind of reverse though), you reverse portions of the array, you'll be given a length argument which represents the length of each portion you are to reverse.

E.g

selReverse([1,2,3,4,5,6], 2)
 //=> [2,1, 4,3, 6,5]

if after reversing some portions of the array and the length of the remaining portion in the array is not up to the length argument, just reverse them.

selReverse([2,4,6,8,10,12,14,16], 3)
 //=> [6,4,2, 12,10,8, 16,14]

selReverse(array, length)

  • array - array to reverse
  • length - length of each portion to reverse

Note : if the length argument exceeds the array length, reverse all of them, if the length argument is zero do not reverse at all.

Algorithms
Logic
Arrays

Stats:

CreatedApr 18, 2017
PublishedApr 19, 2017
Warriors Trained3753
Total Skips92
Total Code Submissions8296
Total Times Completed2287
JavaScript Completions1163
Python Completions915
Crystal Completions17
Ruby Completions174
Groovy Completions59
Nim Completions21
Haskell Completions29
Total Stars64
% of votes with a positive feedback rating94% of 394
Total "Very Satisfied" Votes350
Total "Somewhat Satisfied" Votes40
Total "Not Satisfied" Votes4
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • kodejuice Avatar
  • GiacomoSorbi Avatar
  • JohanWiltink Avatar
  • tachyonlabs Avatar
  • NunoOliveira Avatar
  • metagn Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad