aboutsummaryrefslogtreecommitdiff
path: root/2022/04/puzzles.awk
blob: 8ba715d5884f773b1c5fb8699ebb6042b78c6d6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/awk -f

BEGIN { FS = "[,-]" }
# START PART 1
($1 <= $3 && $2 >= $4) || ($1 >= $3 && $2 <= $4) { c++ }
# END PART 1 START PART 2
($3 >= $1 && $3 <= $2) || ($4 >= $1 && $4 <= $2) ||
       ($1 >= $3 && $1 <= $4) || ($2 >= $3 && $2 <= $4) { c++ }
# END PART 2
END { print c }