-
Notifications
You must be signed in to change notification settings - Fork 0
/
day4.py
32 lines (27 loc) · 1.13 KB
/
day4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
f = open("ressources/day4.txt", "r")
lines = f.readlines()
score = 0
for line in lines:
sections = line.replace("\n", "").split(",")
sections1 = sections[0].split("-")
sections2 = sections[1].split("-")
if int(sections1[0]) <= int(sections2[0]) and int(sections1[1]) >= int(sections2[1]):
score += 1
elif int(sections2[0]) <= int(sections1[0]) and int(sections2[1]) >= int(sections1[1]):
score += 1
print("Your Score is: {}".format(score))
score = 0
for line in lines:
sections = line.replace("\n", "").split(",")
sections1 = sections[0].split("-")
sections2 = sections[1].split("-")
if int(sections2[0]) >= int(sections1[0]) and int(sections2[0]) <= int(sections1[1]):
score += 1
elif int(sections2[1]) >= int(sections1[0]) and int(sections2[1]) <= int(sections1[1]):
score += 1
elif int(sections1[0]) >= int(sections2[0]) and int(sections1[0]) <= int(sections2[1]):
score += 1
elif int(sections1[1]) >= int(sections2[0]) and int(sections1[1]) <= int(sections2[1]):
score += 1
print("Your Score is: {}".format(score))