The (Easy) Road to Code
Python 2, 79 78 73 72 bytes
n,d=input()
c='|\/'[d]
i=n
while i:print' '*(n-i*d)+c,i%2*c or' ',c;i-=1
Try it online!
Takes [1,0,-1]
for [north-west, north, north-east]
-1 byte, thanks to Neil
Python 2, 66 bytes
n,d=input()
s=' '+'|\/'[d]
for c in(s*n)[n:]:print' '*n+s,c+s;n+=d
Try it online!
Uses d=-1
for NE, d=0
for N, and d=1
for NW. Takes advantage of leading spaces being allowed. The rule that the bottom segment of the road have a separator made it tricky to get the parity right; it's achieved by the slicing (s*n)[n:]
taking the second half of the 2n
alternations between space and a the road character.
1. Python 3.5, 122 120 bytes
Script takes two params: n, d.
d: 0, 1, 2 -> \ | /
tio.run
import sys;(n,d)=[*map(int,sys.argv[1:3])];c="\\|/"[d]
for i in range(n):j=n+~i;print(" "*(i,0,j)[d],c,c*(j%2<1)or" ",c)
output:
$ ./script.py 6 2
/ /
/ / /
/ /
/ / /
/ /
/ / /
$ ./script.py 6 1
| |
| | |
| |
| | |
| |
| | |
$ ./script.py 6 0
\ \
\ \ \
\ \
\ \ \
\ \
\ \ \
Explanation
# parse input params
(n,d)=[*map(int,sys.argv[1:3])]
# select char for "road"
c="\\|/"[d]
# loop n-times
for i in range(n):
# complement (how many lines to end)
j=n+~i
# print
# space i or 0 or j times
# road, center of road if j is even else space, road
print(" "*(i,0,j)[d], c, c*(j%2<1) or " ", c)
edit: -2 bytes thanks to Kevin Cruijssen