structured, added solutions 08,07-2022

This commit is contained in:
s-prechtl 2022-12-09 11:54:15 +01:00
parent 27fe77bbe1
commit ee95020aa2
15 changed files with 1428 additions and 111 deletions

View file

@ -0,0 +1,20 @@
if __name__ == '__main__':
elvePairs = []
notNeeded = 0
intersections = 0
with open("input.txt", "r") as f:
for line in f.readlines():
line = line.replace("/n", "")
elveSections = [boundries.split("-") for boundries in line.split(",")]
elvePairs.append([[number for number in range(int(elveSections[0][0]), int(elveSections[0][1]) + 1)],
[number for number in range(int(elveSections[1][0]), int(elveSections[1][1]) + 1)]])
for elvePair in elvePairs:
if set(elvePair[0]).issubset(elvePair[1]) or set(elvePair[1]).issubset(elvePair[0]):
notNeeded += 1
if len(set(elvePair[0]) & set(elvePair[1])) > 0:
intersections += 1
print(f"Solution 1: {notNeeded}")
print(f"Solution 2: {intersections}")