mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
AWK solution for day 4 part 1.
This commit is contained in:
22
2017/day-04/solution.awk
Normal file
22
2017/day-04/solution.awk
Normal file
@@ -0,0 +1,22 @@
|
||||
BEGIN {
|
||||
valid=0
|
||||
}
|
||||
{
|
||||
duplicates=0
|
||||
for (i=1;i<=NF;i++) {
|
||||
a[$i]++
|
||||
}
|
||||
for (x in a)
|
||||
{
|
||||
if(a[x]>1)
|
||||
duplicates++
|
||||
}
|
||||
for (x in a)
|
||||
delete a[x]
|
||||
|
||||
if(duplicates==0)
|
||||
valid++
|
||||
}
|
||||
END {
|
||||
print valid
|
||||
}
|
||||
Reference in New Issue
Block a user