Skip to main content
5 of 5
Commonmark migration

Japt -R, 40 bytes

Æ=Vg"|\\/";²i1S+iX%2?S:U)iSp[TZÊ-YY]gVÃw

Try it online!

Explanation:

Æ=Vg"|\\/";²i1S+iX%2?S:U)iSp[TZÊ-YY]gVÃw
                                            // U = road size
                                            // V = direction
Æ                                     Ã     // Loop X through [0...U]
 =        ;                                 //   Set U to:
    "|\\/"                                  //       "|\/"
  Vg                                        //            [V]
           ²                                //  Double U
            i1          )                   //  Insert at index 1:
              S+                            //    " " +
                 X%2?S:U                    //         X%2?" ":U
                i                           //                  + " "
                         i                  //  Insert at index 0:
                          Sp                //    " " repeated this many times:
                            [TZÊ-YY]        //      [0,U.length - X,X]
                                    gV      //                        [V]
                                        w   // Reverse output
      
  
Oliver
  • 7.9k
  • 2
  • 18
  • 38