day04 - shortened
This commit is contained in:
parent
ce7612c677
commit
0c03d2fff7
14
day04.py
14
day04.py
@ -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__':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user