I was working on phase one of the Dyalog Problem Solving contest for students, and I came across a problem that gave me a bit of trouble: Write a dfn that takes vectors as its left and right arguments and returns them “meshed” into a single vector formed by alternately taking successive elements from each argument. The arguments do not have to be the same length.
Test cases:
‘MENS’ {your_solution} ‘EKES’
MEEKNESS
‘Dyalog’ {your_solution} ‘APL’
DAaPlLog
‘APL’ {your_solution} ‘Dyalog’
ADPyLalog
1 3 5 7 {your_solution} 2 4 6 8 ⍝ should work with numeric vectors
1 2 3 4 5 6 7 8
” {your_solution} ‘Hello’ ⍝ either or both arguments could be empty
Hello
I came to a solution I wasn’t proud of, so I got some feedback from the guys around me. After spending quite some time on what should be a pretty trivial problem I finally reached a solution that I was proud of. I wanted to share this problem to see what sort of solutions everyone could come up with as I know several (distinctly different I might add) have already been found downstairs.
The competition can be found here.
Happy APLing.