-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay4_part2.py
34 lines (31 loc) · 920 Bytes
/
Day4_part2.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
33
34
File = open("Day_4_Input.txt", "r")
Lines = File.readlines()
Solution = 0
for line in Lines:
Elf1 = line.strip().split(",")[0]
StartIdElf1 = int(Elf1.split("-")[0])
EndIdElf1 = int(Elf1.split("-")[1])
Elf2 = line.strip().split(",")[1]
StartIdElf2 = int(Elf2.split("-")[0])
EndIdElf2 = int(Elf2.split("-")[1])
Locations1 = ""
Locations2 = ""
for i in range(0,100):
if i < StartIdElf1 or i > EndIdElf1:
Locations1 += "-"
else:
Locations1 += "X"
if i < StartIdElf2 or i > EndIdElf2:
Locations2 += "-"
else:
Locations2 += "X"
print(Locations1)
print(Locations2)
print("")
if EndIdElf1 >= StartIdElf2 and EndIdElf1 <= EndIdElf2:
Solution += 1
print("+1")
elif EndIdElf2 >= StartIdElf1 and EndIdElf2 <= EndIdElf1:
Solution += 1
print("+1")
print(Solution)