diff --git a/d06/exec1.awk b/d06/exec1.awk new file mode 100644 index 0000000..3535407 --- /dev/null +++ b/d06/exec1.awk @@ -0,0 +1,17 @@ +{ N=0; # use -vW=4 or 14 + for (i=1; ; i++) { + window = substr($0,i,W) + # compare each char of the window to rest of the window + S = 0 # to count match + for (j=1; j j diff --git a/d06/exec3.awk b/d06/exec3.awk new file mode 100644 index 0000000..b189a77 --- /dev/null +++ b/d06/exec3.awk @@ -0,0 +1,13 @@ +{ # use -vW=4 or 14 + for (i=1; ; i++) { + window = substr($0,i,W) + for (j=1; j<=W; j++) { # populate a Set + A[substr(window,j,1)]=1 + } + if (length(A) == W) { + print i + W - 1 + next + } + delete A + } +} # O(N*W*log2(W)) \ No newline at end of file