Browse Source

day4day4day4day4

main
Luna Lailatova 1 year ago
parent
commit
64834c3195
  1. 35
      day4.py
  2. 1000
      input4.txt

35
day4.py

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
with open('input4.txt','r') as f:
inp = f.read().splitlines(keepends=False)
score = 0
score1 = 0
for i in inp:
tempa, tempb = i.split(',')
a1, a2 = map(int, tempa.split('-'))
b1, b2 = map(int, tempb.split('-'))
if a1 <= b1:
if a2 >= b2:
score1 += 1
elif b1 <= a1:
if b2 >= a2:
score1 += 1
elif b1 <= a2:
if b2 >= a2:
score1 += 1
for i in inp:
tempa, tempb = i.split(',')
a1, a2 = map(int, tempa.split('-'))
b1, b2 = map(int, tempb.split('-'))
if b1 <= a1 and a1 <= b2:
score += 1
elif b1 <= a2 and a2 <= b2:
score += 1
elif a1 <= b1 and b1 <= a2:
score += 1
elif a1 <= b2 and b2 <= a2:
score += 1
print('Part1', score1)
print('Part2', score)

1000
input4.txt

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save