Weave Strings Together
Given a list of strings(and optionally, their length) as input, weave the strings together.
Intro
Your goal is to mimic the WV
operator in Pip. Take a list of strings and alternate between their characters like so:
hello,
world, → hwc,eoo,lrd,lle,od → hwceoolrdlleod
code
Effectively, you need to group the characters at each index, and join them into a single string.
The strings may have spaces.
No truncation should be done, and all the characters of each string must be used.
Test Cases
["kino","cinema","movie"] → kcmiionnvoeimea
["code","golf"] → cgoodlef
["Hi","","There"] → HTihere
["Explanation"] → Explanation
["Dyalog APL","Cultivation","Orchard"] → DCOyuralclthoiagvr adAtPiLon
You check any other test cases with this program.
[Haskell], 40 bytes ```hask …
5mo ago
Japt `-P`, 7 2 bytes Õc …
5mo ago
[APL (Dyalog Unicode)], 10 byt …
5mo ago
[JavaScript (Node.js)], 53 byt …
5mo ago
4 answers
APL (Dyalog Unicode), 10 bytes
Full program. Prompts for list of strings from stdin.
0~⍨,⍉↑0,¨⎕
⎕
prompt for list of strings
0,¨
prepend a zero to each
↑
convert to orthogonal matrix (increase rank at cost of depth), padding with 0s
⍉
transpose
,
ravel (flatten)
0~⍨
remove 0s
3 comments
Ugh, the "strings may have spaces" and the way you don't pad the strings makes it unusually annoying. — Quintec 5 months ago
Can we take the strings as an array of characters? — Shaggy 5 months ago
@Shaggy yes, you can — Razetime 5 months ago