Browse Source

cleanups

master
mid-kid 2 years ago
parent
commit
db760b5db3
  1. 4
      d04.cc
  2. 8
      d04.py

4
d04.cc

@ -15,9 +15,7 @@ public:
bool overlaps(const Range &in) { bool overlaps(const Range &in) {
return (min <= in.min && in.min <= max) return (min <= in.min && in.min <= max)
|| (min <= in.max && in.max <= max) || (in.min <= min && min <= in.max);
|| (in.min <= min && min <= in.max)
|| (in.min <= max && max <= in.max);
} }
}; };

8
d04.py

@ -1,12 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from sys import stdin from sys import stdin
data = [(range(int(a1), int(a2)+1), range(int(b1), int(b2)+1)) data = [(range(a1, a2+1), range(b1, b2+1)) for (a1, a2), (b1, b2) in
for (a1, a2), (b1, b2) in [(a.split("-"), b.split("-")) [(map(int, a.split("-")), map(int, b.split("-")))
for a, b in [x.split(",") for x in stdin.readlines()]]] for a, b in [x.split(",") for x in stdin.readlines()]]]
print(sum(all(x in b for x in a) or all(x in a for x in b) for a, b in data)) print(sum(all(x in b for x in a) or all(x in a for x in b) for a, b in data))
print(sum(bool(set(a) & set(b)) for a, b in data)) print(sum(bool(set(a) & set(b)) for a, b in data))
for a, b in data:
if set(a) & set(b):
print((a,b))

Loading…
Cancel
Save