Skip to content

2022-5: Stairway to Heaven

(with apologies to Led Zeppelin)

Write a function that:

  • takes a scalar integer argument, n, in the range 0-100.
  • returns a character matrix comprised of spaces and that resembles an n-level left-to-right ascending stairway.

Hint: The index generator function ⍳Y could help with solving this problem.

Examples:

      
      (your_function) 10
         ⎕
        ⎕⎕
       ⎕⎕⎕
      ⎕⎕⎕⎕
     ⎕⎕⎕⎕⎕
    ⎕⎕⎕⎕⎕⎕
   ⎕⎕⎕⎕⎕⎕⎕
  ⎕⎕⎕⎕⎕⎕⎕⎕
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕
⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

      (your_function) 0 ⍝ returns a 0×0 matrix

your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub