+$2{q=(p=NR-3+2*$1)/$1;for(a=l/$2+3;NR=p;)printf++i-a*$2?i*i%a-1?p%q<2&&i%a?"-":FS:p%q<2?"+":"|":i=A[p--]RS}{l=gsub(/-/,e)}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page