Skip to content

10. Centre Stage

In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.


Using everything you’ve learnt, write a function that takes a width as left argument and a text as right argument, and pads the text with stars (*) on both sides until it has the given width. If the padding can’t be exactly equal to reach the given width, the left side gets one more star than the right. For example:

      10 {answer} 'HI'
****HI****

      10 {answer} 'APL'
****APL***

      11 {answer} 'APL'
****APL****