Skip to content

2019-7: In the Center of It All

Given a right argument of a list of words (or possibly a single word) and a left argument of a width, return a character matrix that has width columns and one row per word, where each word is centered within the row. If width is smaller than the length of a word, truncate the word from the right. If there are an odd number of spaces to center within, leave the extra space on the right.

💡 Hint: The mix ↑Y and rotate X⌽Y functions will probably be useful here.

Examples:

      10 (your_function) 'APL' 'Problem' 'Solving' 'Competition'
   APL   
 Problem   
 Solving  
Competitio
      3 (your_function) 0⍴⊂''   ⍝ result should be 0-row, 3-column matrix      
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub