Skip to main content
4 of 4
added 2647 characters in body
recursive
  • 10.4k
  • 20
  • 36

Stax, 23 bytes

ù╒←∩♂2Ωⁿ¡├∩22♀Ç○=÷â╧δÖ↑

Run and debug it

Input is two integers separated by a space.
The first is d. -1 specifies north-east. 0 for north. 1 for north-west. The second parameter is n. These two values will get implicitly parsed from input and placed on the input stack with n on top. Additionally d will be accessible from the stax's x register since it's the first implicitly parsed value.

For example, input "1 7"

            Main stack      Explanation
            ----------      -----------
;           [7]             peek from input stack
m                           map over integers [1..n] using the rest of the program
                            output each produced value implicitly
  ;         [1 7]           peek from input stack
  +         [8]             add
  .*"       [8 [42 34]]     2 character string literal with codepoints 42 and 34
  @         [42]            get the element at the specified modular index (8)
  0         [42 0]          literal zero
  "|\/"x@   [42 0 92]       get codepoint from string literal at input d (from x register)
  \         [42 [0 92]]     make pair
  :B        ['\ \ \ ']      encode in custom base; it's binary with custom codepoints
  _x*       ['\ \ \ ' 1]    (loop variable) * (input d)
  ;^        ['\ \ \ ' 1 8]  peek from input stack and increment
  %         ['\ \ \ ' 1]    modulus
  6+        ['\ \ \ ' 7]    add 6
  )         [' \ \ \ ']     left-pad to length

Run this one

recursive
  • 10.4k
  • 20
  • 36