7 kyu

Odd-Even String Sort

4,045 of 19,014Joz

Description:

Given a string s, your task is to return another string such that even-indexed and odd-indexed characters of s are grouped and the groups are space-separated. Even-indexed group comes as first, followed by a space, and then by the odd-indexed part.

Examples

input:    "CodeWars" => "CdWr oeas"
           ||||||||      |||| ||||
indices:   01234567      0246 1357

Even indices 0, 2, 4, 6, so we have "CdWr" as the first group.
Odd indices are 1, 3, 5, 7, so the second group is "oeas".
And the final string to return is "Cdwr oeas".

Notes

Tested strings are at least 8 characters long.

Strings
Fundamentals
Sorting

Stats:

CreatedOct 19, 2016
PublishedOct 19, 2016
Warriors Trained23600
Total Skips776
Total Code Submissions38257
Total Times Completed19014
Python Completions4045
JavaScript Completions10821
Ruby Completions309
TypeScript Completions422
C# Completions605
C++ Completions1018
C Completions214
Java Completions1454
Haskell Completions118
NASM Completions17
Lua Completions65
Factor Completions12
Haxe Completions9
Rust Completions110
Go Completions307
D Completions3
Groovy Completions17
Total Stars143
% of votes with a positive feedback rating94% of 1817
Total "Very Satisfied" Votes1614
Total "Somewhat Satisfied" Votes180
Total "Not Satisfied" Votes23
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Joz Avatar
  • raulbc777 Avatar
  • suic Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • user5036852 Avatar
  • Blind4Basics Avatar
  • Souzooka Avatar
  • KenKamau Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • uglywarthog Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • ejini战神 Avatar
  • Mihail_Onuchin Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • gifti Avatar
Ad