Compare commits

..

No commits in common. "f6d828c1a170e1e273e0b859edd4548c42d30f73" and "5cd8ecb9eecc5817a1541e0cb25484f3f5a5a545" have entirely different histories.

1 changed files with 0 additions and 36 deletions

View File

@ -1,36 +0,0 @@
import aocd
from dotenv import load_dotenv
load_dotenv()
puzzle_input = aocd.get_data(day=4, year=2022)
pairs = puzzle_input.split('\n')
pair_number = 0
contained = 0
overlap = 0
for pair in pairs:
pair = list(map(int, pair.replace(',','-').split('-')))
# Contained
if pair[0] <= pair[2] <= pair[3] <= pair[1]:
contained = contained + 1
elif pair[2] <= pair[0] <= pair[1] <= pair[3]:
contained = contained + 1
else:
pass
# Overlapping
if pair[0] <= pair[2] <= pair[1]:
overlap = overlap + 1
elif pair[0] <= pair[3] <= pair[1]:
overlap = overlap + 1
elif pair[2] <= pair[0] <= pair[3]:
overlap = overlap + 1
elif pair[2] <= pair[1] <= pair[3]:
overlap = overlap + 1
else:
pass
print(f'{contained} of the elves\' tasks are contained by others.')
print(f'{overlap} of the tasks overlap.')