From a6ba0ebaf016e6ec8fefa3c1c868045e30eef03b Mon Sep 17 00:00:00 2001 From: setop Date: Tue, 6 Dec 2022 19:33:04 +0100 Subject: [PATCH] day 6, AWK solution --- d06/exec.awk | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 d06/exec.awk diff --git a/d06/exec.awk b/d06/exec.awk new file mode 100644 index 0000000..6e10e5c --- /dev/null +++ b/d06/exec.awk @@ -0,0 +1,19 @@ +BEGIN {W=14} +{ + for (i=1; i<=length($1); i++) { + window = substr($1,i,W) + S=0 + # compare each char of window to all char of window + for (j=1; j<=W; j++) { + for (k=1; k<=W; k++) { + if (substr(window,j,1) == substr(window,k,1)) { + S+=1 + } + } + } + if (S == W) { + print "fin : " i + W - 1 + next + } + } +} \ No newline at end of file