day04 - shortened

This commit is contained in:
Stefan Harmuth 2022-12-04 14:26:58 +01:00
parent ce7612c677
commit 0c03d2fff7

View File

@ -22,20 +22,10 @@ class Day(AOCDay):
yield list(sorted(map(int, s1.split("-")))), list(sorted(map(int, s2.split("-")))) yield list(sorted(map(int, s1.split("-")))), list(sorted(map(int, s2.split("-"))))
def part1(self) -> Any: def part1(self) -> Any:
count = 0 return sum((s1[0] <= s2[0] and s1[1] >= s2[1]) or (s2[0] <= s1[0] and s2[1] >= s1[1]) for s1, s2 in self.get_sections())
for s1, s2 in self.get_sections():
if (s1[0] <= s2[0] and s1[1] >= s2[1]) or (s2[0] <= s1[0] and s2[1] >= s1[1]):
count += 1
return count
def part2(self) -> Any: def part2(self) -> Any:
count = 0 return sum(s1[0] <= s2[0] <= s1[1] or s2[0] <= s1[0] <= s2[1] for s1, s2 in self.get_sections())
for s1, s2 in self.get_sections():
if s1[0] <= s2[0] <= s1[1] or s2[0] <= s1[0] <= s2[1]:
count += 1
return count
if __name__ == '__main__': if __name__ == '__main__':