2024-04-13 23:16:42 +00:00
|
|
|
{ N=0; j=0; # use -vW=4 or 14
|
2024-04-13 21:52:39 +00:00
|
|
|
for (i=1; ; i++) {
|
|
|
|
c = substr($0,i,1);
|
|
|
|
# look backward for a "new j" > j
|
|
|
|
for (k=i-1; k>j; k--) {
|
|
|
|
N++
|
|
|
|
if (substr($0,k,1) == c) {
|
|
|
|
j = k
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((i-j) == W) {
|
|
|
|
print i, "(" N " loops)"
|
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} # O(N*W)
|