Moved 2022 to own dir
This commit is contained in:
24
2022/04/d.py
Normal file
24
2022/04/d.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
pairs = open(os.path.dirname(__file__) +
|
||||
"/input.txt", "r").read().splitlines()
|
||||
|
||||
tot1 = 0
|
||||
tot2 = 0
|
||||
|
||||
for p in pairs:
|
||||
a = p.split(',')[0].split('-')
|
||||
b = p.split(',')[1].split('-')
|
||||
|
||||
set_a = set(range(int(a[0]), int(a[1])+1))
|
||||
set_b = set(range(int(b[0]), int(b[1])+1))
|
||||
|
||||
if (set_a.issubset(set_b) or set_b.issubset(set_a)):
|
||||
tot1 += 1
|
||||
|
||||
if (set_a.intersection(set_b)):
|
||||
tot2 += 1
|
||||
|
||||
|
||||
print("First answer: " + str(tot1))
|
||||
print("Second answer: " + str(tot2))
|
||||
Reference in New Issue
Block a user