6 kyu

Yes No Yes No

725 of 1,427jaels

Description:

Write a code that receives an array of numbers or strings, goes one by one through it while taking one value out, leaving one value in, taking, leaving, and back again to the beginning until all values are out.
It's like a circle of people who decide that every second person will leave it, until the last person is there. So if the last element of the array is taken, the first element that's still there, will stay.
The code returns a new re-arranged array with the taken values by their order. The first value of the initial array is always taken.

Examples:

arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-> [1, 3, 5, 7, 9, 2, 6, 10, 8, 4]

arr = ['this', 'code', 'is', 'right', 'the']
-> ['this', 'is', 'the', 'right', 'code']
Algorithms

More By Author:

Check out these other kata created by jaels

Stats:

CreatedMay 18, 2016
PublishedJun 20, 2016
Warriors Trained4609
Total Skips185
Total Code Submissions13602
Total Times Completed1427
JavaScript Completions613
Python Completions725
Ruby Completions99
Haskell Completions45
Total Stars98
% of votes with a positive feedback rating90% of 302
Total "Very Satisfied" Votes258
Total "Somewhat Satisfied" Votes29
Total "Not Satisfied" Votes15
Total Rank Assessments19
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • jaels Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • GiacomoSorbi Avatar
  • JohanWiltink Avatar
  • Awesome A.D. Avatar
  • hobovsky Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • mauro-1 Avatar
  • Just4FunCoder Avatar
Ad