adventofcode/2022/04/01.py
2022-12-04 14:11:33 +01:00

20 lines
526 B
Python
Executable File

#!/usr/bin/env python3
INPUT_FILE = 'input'
def main():
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
includes = 0
for line in content:
e1, e2 = line.split(',')
e1_from, e1_to = map(int, e1.split('-'))
e2_from, e2_to = map(int, e2.split('-'))
r1 = list(range(e1_from, e1_to +1))
r2 = list(range(e2_from, e2_to +1))
if set(r1).issubset(r2) or set(r2).issubset(r1):
includes += 1
print(includes)
if __name__ == '__main__':
main()