JavaScript:153个字符
我想看看是否可以使用代数来绘制圆图来更快地完成该工作:
s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3}s+=t}}
(c
是五个(x,y)对的数组,圆的中心被展平以保存十个字符。)
输出:
1110000000111111111000000011111111100000001111
1000111110001111100011111000111110001111100011
0011111111100111001111111110011100111111111001
0011111111100000001111111110000000111111111001
0011111110000111000011111000011100001111111001
1000111100001111100001110000111110000111100011
1110000000111111111000000011111111100000001111
1111111100111111111001110011111111100111111111
1111111110001111100011111000111110001111111111
1111111111100000001111111110000000111111111111
159个字符更具可读性:
s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3}s+=t?" ":t}}
输出:
0000000 0000000 0000000
000 000 000 000 000 000
00 00 00 00 00 00
00 0000000 0000000 00
00 0000 0000 0000 0000 00
000 0000 0000 0000 0000 000
0000000 0000000 0000000
00 00 00 00
000 000 000 000
0000000 0000000
在167个字符中,我们有“颜色”:
s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3;h=t?i:h}s+=t?" ":h}}
输出:
8888888 0000000 2222222
888 888 000 000 222 222
88 88 00 00 22 22
88 8844400 0066622 22
88 4444 0044 6600 2266 22
888 4444 0004 6000 2226 222
8888888 0000000 2222222
44 44 66 66
444 444 666 666
4444444 6666666
并且使用189个字符,我还可以使半径r
可调:
r=5;s="";c=[r,0,2*r+1,r,3*r+2,0,4*r+3,r,5*r+4,0];for(y=-r;y<3*r;y++){s+="\n";for(x=0;x<9*r;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-r*r;t&=(d<0?-d:d)>r;h=t?i:h}s+=t?" ":h}}
http://jsfiddle.net/mblase75/5Q6BX/