delete words by nn

w{o=o$0}!w,b=w=$0{gsub(/./,FS,b)
w="|"w
for($(FS=_)=$0;i++<NF;)w=$i w}END{$0=o
s=NF/--NR
for(gsub(w,b);j<NF;j++)p=p$(j*s%NF+j/NR+1)
$0=p
for(gsub(w,b);k<NF;)q=q$(k*NR%NF+k/s+1)(++k%s?_:RS)
print q}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top