IDL 8.3, 135 bytes
#IDL 8.3, 135 bytes
DunnoDunno if this can be golfed more... It's very straightforward. First we create a m x m
array (m=2n+1
) of empty strings; then, we draw the characters in lines (y=x
, y=-x
, y=n
, and x=n
). Then we drop the O in at point (n, n)
, and print the whole thing, formatted as m
strings of length 1 on each line so that there's no extra spacing from printing the array natively.
pro s,n
m=2*n+1
v=strarr(m,m)
x=[0:m-1]
v[x,x]='\'
v[x,m-x-1]='/'
v[n,x]='|'
v[x,n]='-'
v[n,n]='O'
print,v,f='('+strtrim(m,2)+'A1)'
end
Test:
IDL> s,4
\ | /
\ | /
\ | /
\|/
----O----
/|\
/ | \
/ | \
/ | \