5 kyu
Interleaving Arrays
1,158 of 2,158arlaneenalra
Description:
Create a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with empty elements.
Examples:
interleave([1, 2, 3], ["c", "d", "e"]) === [1, "c", 2, "d", 3, "e"]
interleave([1, 2, 3], [4, 5]) === [1, 4, 2, 5, 3, null]
interleave([1, 2, 3], [4, 5, 6], [7, 8, 9]) === [1, 4, 7, 2, 5, 8, 3, 6, 9]
interleave([]) === []
Algorithms
Arrays
Similar Kata:
Stats:
Created | Sep 21, 2013 |
Published | Sep 21, 2013 |
Warriors Trained | 3795 |
Total Skips | 300 |
Total Code Submissions | 14628 |
Total Times Completed | 2158 |
JavaScript Completions | 1158 |
Python Completions | 899 |
Ruby Completions | 105 |
Groovy Completions | 53 |
Total Stars | 66 |
% of votes with a positive feedback rating | 92% of 420 |
Total "Very Satisfied" Votes | 359 |
Total "Somewhat Satisfied" Votes | 54 |
Total "Not Satisfied" Votes | 7 |