1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
BEGIN {
FS = "[-,]";
}
function contains(a, b, x, y) {
return x >= a && y <= b;
}
function overlaps(a, b, x, y) {
return (x >= a && x <= b) || (y >= a && y <= b);
}
{
if (contains($1, $2, $3, $4) || contains($3, $4, $1, $2)) pairs1++;
if (overlaps($1, $2, $4, $4) || overlaps($3, $4, $1, $2)) pairs2++;
}
END {
print pairs1;
print pairs2;
}
|