Javascript 126个字节
for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1&&r%14>1,q=[1,,C&&r&2,,,,C&&~r&2,,1],a+=q[c+5+r&7]?'/':q[r-c+20&7]?'\\':' '
由于现在已经很难理解了,因此有一个基本的解释:
- 我们从左上方到右下方平铺空间
- 我们将其绘制为基本上每6个对角线每8个字符重复一次:2条实线和4条“虚线”(两个字符,然后两个空格...)
- 的
C=...
东西是限制一个边框内的一些线绘制
- 为了节省大量字符,我们故意添加数字以使上下两行的表达式极为相似
- 然后,将表达式本身放入一个稀疏数组中
[1,,C&&...]
,我们将查找该数组。如果有真实价值,我们会画出适当的字符。
--
for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`)) // basic grid tiling
C=c%22>1&&r%14>1, // are we not near the edges
q=[1, // a solid line that always draws
, // a line that never draws
C&&r&2, // a line that draws if not near the edge, and if on the correct "dash" (r&2)
,,,
C&&~r&2, // if not near the edge, and on the opposite "dash" (~r&2)
,1 // the opposite diagonal line that always draws
],
a+=q[c+5+r&7]?'/' // compute which upward line we're on, check whether to draw it
:q[r-c+20&7]?'\\' // do the same for the downward line
:' ' // otherwise draw a space
也许这种解释没有帮助。:)
在线尝试:https://codepen.io/stevebennett/pen/WjgMpY
希望我得到正确的输出:
/\ /\ /\
/ \ / \ / \
/ /\ \ / /\ \ / /\ \
/ / \ \/ / \ \/ / \ \
\ \ / /\ \ / /\ \ / /
\ \/ / \ \/ / \ \/ /
\ / /\ \ / /\ \ /
\/ / \ \/ / \ \/
/\ \ / /\ \ / /\
/ \ \/ / \ \/ / \
/ /\ \ / /\ \ / /\ \
/ / \ \/ / \ \/ / \ \
\ \ / /\ \ / /\ \ / /
\ \/ / \ \/ / \ \/ /
\ / \ / \ /
\/ \/ \/
历史
130
for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1&&r%14>1,q=[1,,C&&r&2,,,,C&&~r&2,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '
133
for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1,q=[1,,C&&r&2&&r<14,,,,C&&~r&2&&r>1,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '
137
for(c=r=a='';r<16;c++==23&&(r++,c=0,a+=`
`))C=c<22&&c>1,q=[1,,C&&r&2&&r<14,,,,C&&~r&2&&r>1,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '
155
for(c=r=a='';r<16;c++==23&&(r++,c=0,a+=`
`))Z=(C=c<22&&c>1)&&~r&2&&r>1,Y=C&&r&2&&r<14,B=(c-r+12)%8,A=(c+5+r)%8,q=[1,,Y,,,,Z,,1],a+=q[A]?'/':q[8-B]?'\\':' '
历史记录:172
for(c=r=a='';r<16;c++==23&&(r++,c=0,a+='\n'))a+=(Z=(C=c<22&&c>1)&&~r&2&&r>3,Y=C&&r&2&&r<12,B=(c-r+16)%8,A=(c+r)%8,A==3||A==5&&Y||A==1&&Z?'/':B==4||B==2&&Y||B==6&&Z?'\\':' ')