advent2020/one.awk

17 lines
383 B
Awk
Executable File

#!/usr/bin/awk -f
{
a[NR] = $1
for(i = 1; i < NR; i++) {
for(j = 1; j < NR; j++) {
for(u = 0;u <= a[j]; u += a[j]) {
#print "if("a[i]" + "u" + "$1" == 2020) {"
if(a[i] + u + $1 == 2020) {
s = a[i] * (u?u:1) * $1
if(!t[s]++) print s
}
}
}
}
}