Skip to main content
6 of 9
deleted 31 characters in body
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 36 35 34 33 bytes

_3”-ẋ“|+“ ||”j
:©2⁶ẋ,`jÇŒḄḊṙ®sṁµY

TryItOnline!

Builds a nighter the other way around to the examples like:

+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+

How?

_3”-ẋ“|+“ ||”j - Link 1, walls+turn/exit: n   e.g. 7
  ”-           - literal ['-']
_3             - n - 3                        e.g. 4
    ẋ          - repeat                       e.g. "----"
     “|+“ ||”  - list of strings ["|+"," ||"]
             j - join                         e.g. "|+---- ||"

:©2⁶ẋ,`jÇŒḄḊṙ®sṁµY - Main link: n             e.g. 7
   ⁶               - literal [' ']
: 2                - integer divide n by 2    e.g. 3
 ©                 - save in register
    ẋ              - repeat                   e.g. "   "
      `            - repeat argument for the dyad:
     ,             -     pair                 e.g. ["   ","   "]
        Ç          - call last link (1) as a monad
       j           - join                     e.g. "   |+---- ||   "
         ŒḄ        - bounce                   e.g. "   |+---- ||     || ----+|   "
           Ḋ       - dequeue                  e.g. "  |+---- ||     || ----+|   "
             ®     - read register            e.g. 3
            ṙ      - rotate left              e.g. "+---- ||     || ----+|     |"
              s    - split into chunks of length n
                                              e.g. ["+---- |",
                                                    "|     |",
                                                    "| ----+",
                                                    "|     |"]
               ṁ   - mould like n (i.e. repeat to fill)
                µ  - monadic chain separation
                 Y - join with line feeds
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282