day 6, AWK solution

This commit is contained in:
setop 2022-12-06 19:33:04 +01:00
parent d34efaa5d1
commit a6ba0ebaf0
1 changed files with 19 additions and 0 deletions

19
d06/exec.awk Normal file
View File

@ -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
}
}
}