Skip to main content
Commonmark migration
Source Link

#MathGolf, 32 bytes

MathGolf, 32 bytes

{kî-⌠ *_£(∞k£+'_*û/ ï*\n}û\/k* k

Try it online.

Explanation:

{             # Loop the (implicit) input amount of times:
 k            #  Push the input-integer
  î-          #  Subtract the 1-based loop-index
    ⌠         #  + 2
      *       #  And repeat that many spaces
 _            #  Duplicate this string
  £           #  Pop and push its length
   (          #  + 1
    ∞         #  * 2
     k        #  Push the input-integer again
      £       #  Pop and push its length
       +      #  Add those two integers together
        '_*  '#  And repeat that many "_"
 û/           #  Push the 2-char string "/ "
    ï*        #  And repeat it the 0-based loop-index amount of times
 \            #  Then swap the top two strings on the stack
 n            #  And push a newline character
}û\/k*        # After the loop: repeat 2-char string "\/" the input amount of times
              # Push a space
 k            # And push the input-integer
              # (after which the stack is joined together and output implicitly)

#MathGolf, 32 bytes

{kî-⌠ *_£(∞k£+'_*û/ ï*\n}û\/k* k

Try it online.

Explanation:

{             # Loop the (implicit) input amount of times:
 k            #  Push the input-integer
  î-          #  Subtract the 1-based loop-index
    ⌠         #  + 2
      *       #  And repeat that many spaces
 _            #  Duplicate this string
  £           #  Pop and push its length
   (          #  + 1
    ∞         #  * 2
     k        #  Push the input-integer again
      £       #  Pop and push its length
       +      #  Add those two integers together
        '_*  '#  And repeat that many "_"
 û/           #  Push the 2-char string "/ "
    ï*        #  And repeat it the 0-based loop-index amount of times
 \            #  Then swap the top two strings on the stack
 n            #  And push a newline character
}û\/k*        # After the loop: repeat 2-char string "\/" the input amount of times
              # Push a space
 k            # And push the input-integer
              # (after which the stack is joined together and output implicitly)

MathGolf, 32 bytes

{kî-⌠ *_£(∞k£+'_*û/ ï*\n}û\/k* k

Try it online.

Explanation:

{             # Loop the (implicit) input amount of times:
 k            #  Push the input-integer
  î-          #  Subtract the 1-based loop-index
    ⌠         #  + 2
      *       #  And repeat that many spaces
 _            #  Duplicate this string
  £           #  Pop and push its length
   (          #  + 1
    ∞         #  * 2
     k        #  Push the input-integer again
      £       #  Pop and push its length
       +      #  Add those two integers together
        '_*  '#  And repeat that many "_"
 û/           #  Push the 2-char string "/ "
    ï*        #  And repeat it the 0-based loop-index amount of times
 \            #  Then swap the top two strings on the stack
 n            #  And push a newline character
}û\/k*        # After the loop: repeat 2-char string "\/" the input amount of times
              # Push a space
 k            # And push the input-integer
              # (after which the stack is joined together and output implicitly)
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#MathGolf, 32 bytes

{kî-⌠ *_£(∞k£+'_*û/ ï*\n}û\/k* k

Try it online.

Explanation:

{             # Loop the (implicit) input amount of times:
 k            #  Push the input-integer
  î-          #  Subtract the 1-based loop-index
    ⌠         #  + 2
      *       #  And repeat that many spaces
 _            #  Duplicate this string
  £           #  Pop and push its length
   (          #  + 1
    ∞         #  * 2
     k        #  Push the input-integer again
      £       #  Pop and push its length
       +      #  Add those two integers together
        '_*  '#  And repeat that many "_"
 û/           #  Push the 2-char string "/ "
    ï*        #  And repeat it the 0-based loop-index amount of times
 \            #  Then swap the top two strings on the stack
 n            #  And push a newline character
}û\/k*        # After the loop: repeat 2-char string "\/" the input amount of times
              # Push a space
 k            # And push the input-integer
              # (after which the stack is joined together and output implicitly)